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