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