scsw.h 24 KB

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