scsw.h 23 KB

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