scsw.h 24 KB

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