scsw.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  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 <peter.oberparleiter@de.ibm.com>
  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. * scsw_is_tm - check for transport mode scsw
  204. * @scsw: pointer to scsw
  205. *
  206. * Return non-zero if the specified scsw is a transport mode scsw, zero
  207. * otherwise.
  208. */
  209. static inline int scsw_is_tm(union scsw *scsw)
  210. {
  211. return css_general_characteristics.fcx && (scsw->tm.x == 1);
  212. }
  213. /**
  214. * scsw_key - return scsw key field
  215. * @scsw: pointer to scsw
  216. *
  217. * Return the value of the key field of the specified scsw, regardless of
  218. * whether it is a transport mode or command mode scsw.
  219. */
  220. static inline u32 scsw_key(union scsw *scsw)
  221. {
  222. if (scsw_is_tm(scsw))
  223. return scsw->tm.key;
  224. else
  225. return scsw->cmd.key;
  226. }
  227. /**
  228. * scsw_eswf - return scsw eswf field
  229. * @scsw: pointer to scsw
  230. *
  231. * Return the value of the eswf field of the specified scsw, regardless of
  232. * whether it is a transport mode or command mode scsw.
  233. */
  234. static inline u32 scsw_eswf(union scsw *scsw)
  235. {
  236. if (scsw_is_tm(scsw))
  237. return scsw->tm.eswf;
  238. else
  239. return scsw->cmd.eswf;
  240. }
  241. /**
  242. * scsw_cc - return scsw cc field
  243. * @scsw: pointer to scsw
  244. *
  245. * Return the value of the cc field of the specified scsw, regardless of
  246. * whether it is a transport mode or command mode scsw.
  247. */
  248. static inline u32 scsw_cc(union scsw *scsw)
  249. {
  250. if (scsw_is_tm(scsw))
  251. return scsw->tm.cc;
  252. else
  253. return scsw->cmd.cc;
  254. }
  255. /**
  256. * scsw_ectl - return scsw ectl field
  257. * @scsw: pointer to scsw
  258. *
  259. * Return the value of the ectl field of the specified scsw, regardless of
  260. * whether it is a transport mode or command mode scsw.
  261. */
  262. static inline u32 scsw_ectl(union scsw *scsw)
  263. {
  264. if (scsw_is_tm(scsw))
  265. return scsw->tm.ectl;
  266. else
  267. return scsw->cmd.ectl;
  268. }
  269. /**
  270. * scsw_pno - return scsw pno field
  271. * @scsw: pointer to scsw
  272. *
  273. * Return the value of the pno field of the specified scsw, regardless of
  274. * whether it is a transport mode or command mode scsw.
  275. */
  276. static inline u32 scsw_pno(union scsw *scsw)
  277. {
  278. if (scsw_is_tm(scsw))
  279. return scsw->tm.pno;
  280. else
  281. return scsw->cmd.pno;
  282. }
  283. /**
  284. * scsw_fctl - return scsw fctl field
  285. * @scsw: pointer to scsw
  286. *
  287. * Return the value of the fctl field of the specified scsw, regardless of
  288. * whether it is a transport mode or command mode scsw.
  289. */
  290. static inline u32 scsw_fctl(union scsw *scsw)
  291. {
  292. if (scsw_is_tm(scsw))
  293. return scsw->tm.fctl;
  294. else
  295. return scsw->cmd.fctl;
  296. }
  297. /**
  298. * scsw_actl - return scsw actl field
  299. * @scsw: pointer to scsw
  300. *
  301. * Return the value of the actl field of the specified scsw, regardless of
  302. * whether it is a transport mode or command mode scsw.
  303. */
  304. static inline u32 scsw_actl(union scsw *scsw)
  305. {
  306. if (scsw_is_tm(scsw))
  307. return scsw->tm.actl;
  308. else
  309. return scsw->cmd.actl;
  310. }
  311. /**
  312. * scsw_stctl - return scsw stctl field
  313. * @scsw: pointer to scsw
  314. *
  315. * Return the value of the stctl field of the specified scsw, regardless of
  316. * whether it is a transport mode or command mode scsw.
  317. */
  318. static inline u32 scsw_stctl(union scsw *scsw)
  319. {
  320. if (scsw_is_tm(scsw))
  321. return scsw->tm.stctl;
  322. else
  323. return scsw->cmd.stctl;
  324. }
  325. /**
  326. * scsw_dstat - return scsw dstat field
  327. * @scsw: pointer to scsw
  328. *
  329. * Return the value of the dstat field of the specified scsw, regardless of
  330. * whether it is a transport mode or command mode scsw.
  331. */
  332. static inline u32 scsw_dstat(union scsw *scsw)
  333. {
  334. if (scsw_is_tm(scsw))
  335. return scsw->tm.dstat;
  336. else
  337. return scsw->cmd.dstat;
  338. }
  339. /**
  340. * scsw_cstat - return scsw cstat field
  341. * @scsw: pointer to scsw
  342. *
  343. * Return the value of the cstat field of the specified scsw, regardless of
  344. * whether it is a transport mode or command mode scsw.
  345. */
  346. static inline u32 scsw_cstat(union scsw *scsw)
  347. {
  348. if (scsw_is_tm(scsw))
  349. return scsw->tm.cstat;
  350. else
  351. return scsw->cmd.cstat;
  352. }
  353. /**
  354. * scsw_cmd_is_valid_key - check key field validity
  355. * @scsw: pointer to scsw
  356. *
  357. * Return non-zero if the key field of the specified command mode scsw is
  358. * valid, zero otherwise.
  359. */
  360. static inline int scsw_cmd_is_valid_key(union scsw *scsw)
  361. {
  362. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  363. }
  364. /**
  365. * scsw_cmd_is_valid_sctl - check sctl field validity
  366. * @scsw: pointer to scsw
  367. *
  368. * Return non-zero if the sctl field of the specified command mode scsw is
  369. * valid, zero otherwise.
  370. */
  371. static inline int scsw_cmd_is_valid_sctl(union scsw *scsw)
  372. {
  373. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  374. }
  375. /**
  376. * scsw_cmd_is_valid_eswf - check eswf field validity
  377. * @scsw: pointer to scsw
  378. *
  379. * Return non-zero if the eswf field of the specified command mode scsw is
  380. * valid, zero otherwise.
  381. */
  382. static inline int scsw_cmd_is_valid_eswf(union scsw *scsw)
  383. {
  384. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
  385. }
  386. /**
  387. * scsw_cmd_is_valid_cc - check cc field validity
  388. * @scsw: pointer to scsw
  389. *
  390. * Return non-zero if the cc field of the specified command mode scsw is
  391. * valid, zero otherwise.
  392. */
  393. static inline int scsw_cmd_is_valid_cc(union scsw *scsw)
  394. {
  395. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
  396. (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
  397. }
  398. /**
  399. * scsw_cmd_is_valid_fmt - check fmt field validity
  400. * @scsw: pointer to scsw
  401. *
  402. * Return non-zero if the fmt field of the specified command mode scsw is
  403. * valid, zero otherwise.
  404. */
  405. static inline int scsw_cmd_is_valid_fmt(union scsw *scsw)
  406. {
  407. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  408. }
  409. /**
  410. * scsw_cmd_is_valid_pfch - check pfch field validity
  411. * @scsw: pointer to scsw
  412. *
  413. * Return non-zero if the pfch field of the specified command mode scsw is
  414. * valid, zero otherwise.
  415. */
  416. static inline int scsw_cmd_is_valid_pfch(union scsw *scsw)
  417. {
  418. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  419. }
  420. /**
  421. * scsw_cmd_is_valid_isic - check isic field validity
  422. * @scsw: pointer to scsw
  423. *
  424. * Return non-zero if the isic field of the specified command mode scsw is
  425. * valid, zero otherwise.
  426. */
  427. static inline int scsw_cmd_is_valid_isic(union scsw *scsw)
  428. {
  429. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  430. }
  431. /**
  432. * scsw_cmd_is_valid_alcc - check alcc field validity
  433. * @scsw: pointer to scsw
  434. *
  435. * Return non-zero if the alcc field of the specified command mode scsw is
  436. * valid, zero otherwise.
  437. */
  438. static inline int scsw_cmd_is_valid_alcc(union scsw *scsw)
  439. {
  440. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  441. }
  442. /**
  443. * scsw_cmd_is_valid_ssi - check ssi field validity
  444. * @scsw: pointer to scsw
  445. *
  446. * Return non-zero if the ssi field of the specified command mode scsw is
  447. * valid, zero otherwise.
  448. */
  449. static inline int scsw_cmd_is_valid_ssi(union scsw *scsw)
  450. {
  451. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  452. }
  453. /**
  454. * scsw_cmd_is_valid_zcc - check zcc field validity
  455. * @scsw: pointer to scsw
  456. *
  457. * Return non-zero if the zcc field of the specified command mode scsw is
  458. * valid, zero otherwise.
  459. */
  460. static inline int scsw_cmd_is_valid_zcc(union scsw *scsw)
  461. {
  462. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
  463. (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS);
  464. }
  465. /**
  466. * scsw_cmd_is_valid_ectl - check ectl field validity
  467. * @scsw: pointer to scsw
  468. *
  469. * Return non-zero if the ectl field of the specified command mode scsw is
  470. * valid, zero otherwise.
  471. */
  472. static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
  473. {
  474. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  475. !(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
  476. (scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS);
  477. }
  478. /**
  479. * scsw_cmd_is_valid_pno - check pno field validity
  480. * @scsw: pointer to scsw
  481. *
  482. * Return non-zero if the pno field of the specified command mode scsw is
  483. * valid, zero otherwise.
  484. */
  485. static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
  486. {
  487. return (scsw->cmd.fctl != 0) &&
  488. (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  489. (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) ||
  490. ((scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
  491. (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)));
  492. }
  493. /**
  494. * scsw_cmd_is_valid_fctl - check fctl field validity
  495. * @scsw: pointer to scsw
  496. *
  497. * Return non-zero if the fctl field of the specified command mode scsw is
  498. * valid, zero otherwise.
  499. */
  500. static inline int scsw_cmd_is_valid_fctl(union scsw *scsw)
  501. {
  502. /* Only valid if pmcw.dnv == 1*/
  503. return 1;
  504. }
  505. /**
  506. * scsw_cmd_is_valid_actl - check actl field validity
  507. * @scsw: pointer to scsw
  508. *
  509. * Return non-zero if the actl field of the specified command mode scsw is
  510. * valid, zero otherwise.
  511. */
  512. static inline int scsw_cmd_is_valid_actl(union scsw *scsw)
  513. {
  514. /* Only valid if pmcw.dnv == 1*/
  515. return 1;
  516. }
  517. /**
  518. * scsw_cmd_is_valid_stctl - check stctl field validity
  519. * @scsw: pointer to scsw
  520. *
  521. * Return non-zero if the stctl field of the specified command mode scsw is
  522. * valid, zero otherwise.
  523. */
  524. static inline int scsw_cmd_is_valid_stctl(union scsw *scsw)
  525. {
  526. /* Only valid if pmcw.dnv == 1*/
  527. return 1;
  528. }
  529. /**
  530. * scsw_cmd_is_valid_dstat - check dstat field validity
  531. * @scsw: pointer to scsw
  532. *
  533. * Return non-zero if the dstat field of the specified command mode scsw is
  534. * valid, zero otherwise.
  535. */
  536. static inline int scsw_cmd_is_valid_dstat(union scsw *scsw)
  537. {
  538. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  539. (scsw->cmd.cc != 3);
  540. }
  541. /**
  542. * scsw_cmd_is_valid_cstat - check cstat field validity
  543. * @scsw: pointer to scsw
  544. *
  545. * Return non-zero if the cstat field of the specified command mode scsw is
  546. * valid, zero otherwise.
  547. */
  548. static inline int scsw_cmd_is_valid_cstat(union scsw *scsw)
  549. {
  550. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  551. (scsw->cmd.cc != 3);
  552. }
  553. /**
  554. * scsw_tm_is_valid_key - check key field validity
  555. * @scsw: pointer to scsw
  556. *
  557. * Return non-zero if the key field of the specified transport mode scsw is
  558. * valid, zero otherwise.
  559. */
  560. static inline int scsw_tm_is_valid_key(union scsw *scsw)
  561. {
  562. return (scsw->tm.fctl & SCSW_FCTL_START_FUNC);
  563. }
  564. /**
  565. * scsw_tm_is_valid_eswf - check eswf field validity
  566. * @scsw: pointer to scsw
  567. *
  568. * Return non-zero if the eswf field of the specified transport mode scsw is
  569. * valid, zero otherwise.
  570. */
  571. static inline int scsw_tm_is_valid_eswf(union scsw *scsw)
  572. {
  573. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
  574. }
  575. /**
  576. * scsw_tm_is_valid_cc - check cc field validity
  577. * @scsw: pointer to scsw
  578. *
  579. * Return non-zero if the cc field of the specified transport mode scsw is
  580. * valid, zero otherwise.
  581. */
  582. static inline int scsw_tm_is_valid_cc(union scsw *scsw)
  583. {
  584. return (scsw->tm.fctl & SCSW_FCTL_START_FUNC) &&
  585. (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
  586. }
  587. /**
  588. * scsw_tm_is_valid_fmt - check fmt field validity
  589. * @scsw: pointer to scsw
  590. *
  591. * Return non-zero if the fmt field of the specified transport mode scsw is
  592. * valid, zero otherwise.
  593. */
  594. static inline int scsw_tm_is_valid_fmt(union scsw *scsw)
  595. {
  596. return 1;
  597. }
  598. /**
  599. * scsw_tm_is_valid_x - check x field validity
  600. * @scsw: pointer to scsw
  601. *
  602. * Return non-zero if the x field of the specified transport mode scsw is
  603. * valid, zero otherwise.
  604. */
  605. static inline int scsw_tm_is_valid_x(union scsw *scsw)
  606. {
  607. return 1;
  608. }
  609. /**
  610. * scsw_tm_is_valid_q - check q field validity
  611. * @scsw: pointer to scsw
  612. *
  613. * Return non-zero if the q field of the specified transport mode scsw is
  614. * valid, zero otherwise.
  615. */
  616. static inline int scsw_tm_is_valid_q(union scsw *scsw)
  617. {
  618. return 1;
  619. }
  620. /**
  621. * scsw_tm_is_valid_ectl - check ectl field validity
  622. * @scsw: pointer to scsw
  623. *
  624. * Return non-zero if the ectl field of the specified transport mode scsw is
  625. * valid, zero otherwise.
  626. */
  627. static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
  628. {
  629. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  630. !(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
  631. (scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS);
  632. }
  633. /**
  634. * scsw_tm_is_valid_pno - check pno field validity
  635. * @scsw: pointer to scsw
  636. *
  637. * Return non-zero if the pno field of the specified transport mode scsw is
  638. * valid, zero otherwise.
  639. */
  640. static inline int scsw_tm_is_valid_pno(union scsw *scsw)
  641. {
  642. return (scsw->tm.fctl != 0) &&
  643. (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  644. (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) ||
  645. ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
  646. (scsw->tm.actl & SCSW_ACTL_SUSPENDED)));
  647. }
  648. /**
  649. * scsw_tm_is_valid_fctl - check fctl field validity
  650. * @scsw: pointer to scsw
  651. *
  652. * Return non-zero if the fctl field of the specified transport mode scsw is
  653. * valid, zero otherwise.
  654. */
  655. static inline int scsw_tm_is_valid_fctl(union scsw *scsw)
  656. {
  657. /* Only valid if pmcw.dnv == 1*/
  658. return 1;
  659. }
  660. /**
  661. * scsw_tm_is_valid_actl - check actl field validity
  662. * @scsw: pointer to scsw
  663. *
  664. * Return non-zero if the actl field of the specified transport mode scsw is
  665. * valid, zero otherwise.
  666. */
  667. static inline int scsw_tm_is_valid_actl(union scsw *scsw)
  668. {
  669. /* Only valid if pmcw.dnv == 1*/
  670. return 1;
  671. }
  672. /**
  673. * scsw_tm_is_valid_stctl - check stctl field validity
  674. * @scsw: pointer to scsw
  675. *
  676. * Return non-zero if the stctl field of the specified transport mode scsw is
  677. * valid, zero otherwise.
  678. */
  679. static inline int scsw_tm_is_valid_stctl(union scsw *scsw)
  680. {
  681. /* Only valid if pmcw.dnv == 1*/
  682. return 1;
  683. }
  684. /**
  685. * scsw_tm_is_valid_dstat - check dstat field validity
  686. * @scsw: pointer to scsw
  687. *
  688. * Return non-zero if the dstat field of the specified transport mode scsw is
  689. * valid, zero otherwise.
  690. */
  691. static inline int scsw_tm_is_valid_dstat(union scsw *scsw)
  692. {
  693. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  694. (scsw->tm.cc != 3);
  695. }
  696. /**
  697. * scsw_tm_is_valid_cstat - check cstat field validity
  698. * @scsw: pointer to scsw
  699. *
  700. * Return non-zero if the cstat field of the specified transport mode scsw is
  701. * valid, zero otherwise.
  702. */
  703. static inline int scsw_tm_is_valid_cstat(union scsw *scsw)
  704. {
  705. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  706. (scsw->tm.cc != 3);
  707. }
  708. /**
  709. * scsw_tm_is_valid_fcxs - check fcxs field validity
  710. * @scsw: pointer to scsw
  711. *
  712. * Return non-zero if the fcxs field of the specified transport mode scsw is
  713. * valid, zero otherwise.
  714. */
  715. static inline int scsw_tm_is_valid_fcxs(union scsw *scsw)
  716. {
  717. return 1;
  718. }
  719. /**
  720. * scsw_tm_is_valid_schxs - check schxs field validity
  721. * @scsw: pointer to scsw
  722. *
  723. * Return non-zero if the schxs field of the specified transport mode scsw is
  724. * valid, zero otherwise.
  725. */
  726. static inline int scsw_tm_is_valid_schxs(union scsw *scsw)
  727. {
  728. return (scsw->tm.cstat & (SCHN_STAT_PROG_CHECK |
  729. SCHN_STAT_INTF_CTRL_CHK |
  730. SCHN_STAT_PROT_CHECK |
  731. SCHN_STAT_CHN_DATA_CHK));
  732. }
  733. /**
  734. * scsw_is_valid_actl - check actl field validity
  735. * @scsw: pointer to scsw
  736. *
  737. * Return non-zero if the actl field of the specified scsw is valid,
  738. * regardless of whether it is a transport mode or command mode scsw.
  739. * Return zero if the field does not contain a valid value.
  740. */
  741. static inline int scsw_is_valid_actl(union scsw *scsw)
  742. {
  743. if (scsw_is_tm(scsw))
  744. return scsw_tm_is_valid_actl(scsw);
  745. else
  746. return scsw_cmd_is_valid_actl(scsw);
  747. }
  748. /**
  749. * scsw_is_valid_cc - check cc field validity
  750. * @scsw: pointer to scsw
  751. *
  752. * Return non-zero if the cc field of the specified scsw is valid,
  753. * regardless of whether it is a transport mode or command mode scsw.
  754. * Return zero if the field does not contain a valid value.
  755. */
  756. static inline int scsw_is_valid_cc(union scsw *scsw)
  757. {
  758. if (scsw_is_tm(scsw))
  759. return scsw_tm_is_valid_cc(scsw);
  760. else
  761. return scsw_cmd_is_valid_cc(scsw);
  762. }
  763. /**
  764. * scsw_is_valid_cstat - check cstat field validity
  765. * @scsw: pointer to scsw
  766. *
  767. * Return non-zero if the cstat field of the specified scsw is valid,
  768. * regardless of whether it is a transport mode or command mode scsw.
  769. * Return zero if the field does not contain a valid value.
  770. */
  771. static inline int scsw_is_valid_cstat(union scsw *scsw)
  772. {
  773. if (scsw_is_tm(scsw))
  774. return scsw_tm_is_valid_cstat(scsw);
  775. else
  776. return scsw_cmd_is_valid_cstat(scsw);
  777. }
  778. /**
  779. * scsw_is_valid_dstat - check dstat field validity
  780. * @scsw: pointer to scsw
  781. *
  782. * Return non-zero if the dstat field of the specified scsw is valid,
  783. * regardless of whether it is a transport mode or command mode scsw.
  784. * Return zero if the field does not contain a valid value.
  785. */
  786. static inline int scsw_is_valid_dstat(union scsw *scsw)
  787. {
  788. if (scsw_is_tm(scsw))
  789. return scsw_tm_is_valid_dstat(scsw);
  790. else
  791. return scsw_cmd_is_valid_dstat(scsw);
  792. }
  793. /**
  794. * scsw_is_valid_ectl - check ectl field validity
  795. * @scsw: pointer to scsw
  796. *
  797. * Return non-zero if the ectl field of the specified scsw is valid,
  798. * regardless of whether it is a transport mode or command mode scsw.
  799. * Return zero if the field does not contain a valid value.
  800. */
  801. static inline int scsw_is_valid_ectl(union scsw *scsw)
  802. {
  803. if (scsw_is_tm(scsw))
  804. return scsw_tm_is_valid_ectl(scsw);
  805. else
  806. return scsw_cmd_is_valid_ectl(scsw);
  807. }
  808. /**
  809. * scsw_is_valid_eswf - check eswf field validity
  810. * @scsw: pointer to scsw
  811. *
  812. * Return non-zero if the eswf field of the specified scsw is valid,
  813. * regardless of whether it is a transport mode or command mode scsw.
  814. * Return zero if the field does not contain a valid value.
  815. */
  816. static inline int scsw_is_valid_eswf(union scsw *scsw)
  817. {
  818. if (scsw_is_tm(scsw))
  819. return scsw_tm_is_valid_eswf(scsw);
  820. else
  821. return scsw_cmd_is_valid_eswf(scsw);
  822. }
  823. /**
  824. * scsw_is_valid_fctl - check fctl field validity
  825. * @scsw: pointer to scsw
  826. *
  827. * Return non-zero if the fctl field of the specified scsw is valid,
  828. * regardless of whether it is a transport mode or command mode scsw.
  829. * Return zero if the field does not contain a valid value.
  830. */
  831. static inline int scsw_is_valid_fctl(union scsw *scsw)
  832. {
  833. if (scsw_is_tm(scsw))
  834. return scsw_tm_is_valid_fctl(scsw);
  835. else
  836. return scsw_cmd_is_valid_fctl(scsw);
  837. }
  838. /**
  839. * scsw_is_valid_key - check key field validity
  840. * @scsw: pointer to scsw
  841. *
  842. * Return non-zero if the key field of the specified scsw is valid,
  843. * regardless of whether it is a transport mode or command mode scsw.
  844. * Return zero if the field does not contain a valid value.
  845. */
  846. static inline int scsw_is_valid_key(union scsw *scsw)
  847. {
  848. if (scsw_is_tm(scsw))
  849. return scsw_tm_is_valid_key(scsw);
  850. else
  851. return scsw_cmd_is_valid_key(scsw);
  852. }
  853. /**
  854. * scsw_is_valid_pno - check pno field validity
  855. * @scsw: pointer to scsw
  856. *
  857. * Return non-zero if the pno field of the specified scsw is valid,
  858. * regardless of whether it is a transport mode or command mode scsw.
  859. * Return zero if the field does not contain a valid value.
  860. */
  861. static inline int scsw_is_valid_pno(union scsw *scsw)
  862. {
  863. if (scsw_is_tm(scsw))
  864. return scsw_tm_is_valid_pno(scsw);
  865. else
  866. return scsw_cmd_is_valid_pno(scsw);
  867. }
  868. /**
  869. * scsw_is_valid_stctl - check stctl field validity
  870. * @scsw: pointer to scsw
  871. *
  872. * Return non-zero if the stctl field of the specified scsw is valid,
  873. * regardless of whether it is a transport mode or command mode scsw.
  874. * Return zero if the field does not contain a valid value.
  875. */
  876. static inline int scsw_is_valid_stctl(union scsw *scsw)
  877. {
  878. if (scsw_is_tm(scsw))
  879. return scsw_tm_is_valid_stctl(scsw);
  880. else
  881. return scsw_cmd_is_valid_stctl(scsw);
  882. }
  883. /**
  884. * scsw_cmd_is_solicited - check for solicited scsw
  885. * @scsw: pointer to scsw
  886. *
  887. * Return non-zero if the command mode scsw indicates that the associated
  888. * status condition is solicited, zero if it is unsolicited.
  889. */
  890. static inline int scsw_cmd_is_solicited(union scsw *scsw)
  891. {
  892. return (scsw->cmd.cc != 0) || (scsw->cmd.stctl !=
  893. (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
  894. }
  895. /**
  896. * scsw_tm_is_solicited - check for solicited scsw
  897. * @scsw: pointer to scsw
  898. *
  899. * Return non-zero if the transport mode scsw indicates that the associated
  900. * status condition is solicited, zero if it is unsolicited.
  901. */
  902. static inline int scsw_tm_is_solicited(union scsw *scsw)
  903. {
  904. return (scsw->tm.cc != 0) || (scsw->tm.stctl !=
  905. (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
  906. }
  907. /**
  908. * scsw_is_solicited - check for solicited scsw
  909. * @scsw: pointer to scsw
  910. *
  911. * Return non-zero if the transport or command mode scsw indicates that the
  912. * associated status condition is solicited, zero if it is unsolicited.
  913. */
  914. static inline int scsw_is_solicited(union scsw *scsw)
  915. {
  916. if (scsw_is_tm(scsw))
  917. return scsw_tm_is_solicited(scsw);
  918. else
  919. return scsw_cmd_is_solicited(scsw);
  920. }
  921. #endif /* _ASM_S390_SCSW_H_ */