Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
scsw.h
Go to the documentation of this file.
1 /*
2  * Helper functions for scsw access.
3  *
4  * Copyright IBM Corp. 2008, 2012
5  * Author(s): Peter Oberparleiter <[email protected]>
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 
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;
56  __u32 dstat : 8;
57  __u32 cstat : 8;
58  __u32 count : 16;
59 } __attribute__ ((packed));
60 
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;
98  u32 fcxs:8;
100 } __attribute__ ((packed));
101 
115 struct eadm_scsw {
116  u32 key:4;
117  u32:1;
119  u32 cc:2;
120  u32:6;
122  u32:2;
129  u32:16;
130 } __packed;
131 
138 union scsw {
139  struct cmd_scsw cmd;
140  struct tm_scsw tm;
141  struct eadm_scsw eadm;
142 } __packed;
143 
144 #define SCSW_FCTL_CLEAR_FUNC 0x1
145 #define SCSW_FCTL_HALT_FUNC 0x2
146 #define SCSW_FCTL_START_FUNC 0x4
147 
148 #define SCSW_ACTL_SUSPENDED 0x1
149 #define SCSW_ACTL_DEVACT 0x2
150 #define SCSW_ACTL_SCHACT 0x4
151 #define SCSW_ACTL_CLEAR_PEND 0x8
152 #define SCSW_ACTL_HALT_PEND 0x10
153 #define SCSW_ACTL_START_PEND 0x20
154 #define SCSW_ACTL_RESUME_PEND 0x40
155 
156 #define SCSW_STCTL_STATUS_PEND 0x1
157 #define SCSW_STCTL_SEC_STATUS 0x2
158 #define SCSW_STCTL_PRIM_STATUS 0x4
159 #define SCSW_STCTL_INTER_STATUS 0x8
160 #define SCSW_STCTL_ALERT_STATUS 0x10
161 
162 #define DEV_STAT_ATTENTION 0x80
163 #define DEV_STAT_STAT_MOD 0x40
164 #define DEV_STAT_CU_END 0x20
165 #define DEV_STAT_BUSY 0x10
166 #define DEV_STAT_CHN_END 0x08
167 #define DEV_STAT_DEV_END 0x04
168 #define DEV_STAT_UNIT_CHECK 0x02
169 #define DEV_STAT_UNIT_EXCEP 0x01
170 
171 #define SCHN_STAT_PCI 0x80
172 #define SCHN_STAT_INCORR_LEN 0x40
173 #define SCHN_STAT_PROG_CHECK 0x20
174 #define SCHN_STAT_PROT_CHECK 0x10
175 #define SCHN_STAT_CHN_DATA_CHK 0x08
176 #define SCHN_STAT_CHN_CTRL_CHK 0x04
177 #define SCHN_STAT_INTF_CTRL_CHK 0x02
178 #define SCHN_STAT_CHAIN_CHECK 0x01
179 
180 /*
181  * architectured values for first sense byte
182  */
183 #define SNS0_CMD_REJECT 0x80
184 #define SNS_CMD_REJECT SNS0_CMD_REJEC
185 #define SNS0_INTERVENTION_REQ 0x40
186 #define SNS0_BUS_OUT_CHECK 0x20
187 #define SNS0_EQUIPMENT_CHECK 0x10
188 #define SNS0_DATA_CHECK 0x08
189 #define SNS0_OVERRUN 0x04
190 #define SNS0_INCOMPL_DOMAIN 0x01
191 
192 /*
193  * architectured values for second sense byte
194  */
195 #define SNS1_PERM_ERR 0x80
196 #define SNS1_INV_TRACK_FORMAT 0x40
197 #define SNS1_EOC 0x20
198 #define SNS1_MESSAGE_TO_OPER 0x10
199 #define SNS1_NO_REC_FOUND 0x08
200 #define SNS1_FILE_PROTECTED 0x04
201 #define SNS1_WRITE_INHIBITED 0x02
202 #define SNS1_INPRECISE_END 0x01
203 
204 /*
205  * architectured values for third sense byte
206  */
207 #define SNS2_REQ_INH_WRITE 0x80
208 #define SNS2_CORRECTABLE 0x40
209 #define SNS2_FIRST_LOG_ERR 0x20
210 #define SNS2_ENV_DATA_PRESENT 0x10
211 #define SNS2_INPRECISE_END 0x04
212 
220 static inline int scsw_is_tm(union scsw *scsw)
221 {
222  return css_general_characteristics.fcx && (scsw->tm.x == 1);
223 }
224 
232 static inline u32 scsw_key(union scsw *scsw)
233 {
234  if (scsw_is_tm(scsw))
235  return scsw->tm.key;
236  else
237  return scsw->cmd.key;
238 }
239 
247 static inline u32 scsw_eswf(union scsw *scsw)
248 {
249  if (scsw_is_tm(scsw))
250  return scsw->tm.eswf;
251  else
252  return scsw->cmd.eswf;
253 }
254 
262 static inline u32 scsw_cc(union scsw *scsw)
263 {
264  if (scsw_is_tm(scsw))
265  return scsw->tm.cc;
266  else
267  return scsw->cmd.cc;
268 }
269 
277 static inline u32 scsw_ectl(union scsw *scsw)
278 {
279  if (scsw_is_tm(scsw))
280  return scsw->tm.ectl;
281  else
282  return scsw->cmd.ectl;
283 }
284 
292 static inline u32 scsw_pno(union scsw *scsw)
293 {
294  if (scsw_is_tm(scsw))
295  return scsw->tm.pno;
296  else
297  return scsw->cmd.pno;
298 }
299 
307 static inline u32 scsw_fctl(union scsw *scsw)
308 {
309  if (scsw_is_tm(scsw))
310  return scsw->tm.fctl;
311  else
312  return scsw->cmd.fctl;
313 }
314 
322 static inline u32 scsw_actl(union scsw *scsw)
323 {
324  if (scsw_is_tm(scsw))
325  return scsw->tm.actl;
326  else
327  return scsw->cmd.actl;
328 }
329 
337 static inline u32 scsw_stctl(union scsw *scsw)
338 {
339  if (scsw_is_tm(scsw))
340  return scsw->tm.stctl;
341  else
342  return scsw->cmd.stctl;
343 }
344 
352 static inline u32 scsw_dstat(union scsw *scsw)
353 {
354  if (scsw_is_tm(scsw))
355  return scsw->tm.dstat;
356  else
357  return scsw->cmd.dstat;
358 }
359 
367 static inline u32 scsw_cstat(union scsw *scsw)
368 {
369  if (scsw_is_tm(scsw))
370  return scsw->tm.cstat;
371  else
372  return scsw->cmd.cstat;
373 }
374 
382 static inline int scsw_cmd_is_valid_key(union scsw *scsw)
383 {
384  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
385 }
386 
394 static inline int scsw_cmd_is_valid_sctl(union scsw *scsw)
395 {
396  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
397 }
398 
406 static inline int scsw_cmd_is_valid_eswf(union scsw *scsw)
407 {
408  return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
409 }
410 
418 static inline int scsw_cmd_is_valid_cc(union scsw *scsw)
419 {
420  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
421  (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
422 }
423 
431 static inline int scsw_cmd_is_valid_fmt(union scsw *scsw)
432 {
433  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
434 }
435 
443 static inline int scsw_cmd_is_valid_pfch(union scsw *scsw)
444 {
445  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
446 }
447 
455 static inline int scsw_cmd_is_valid_isic(union scsw *scsw)
456 {
457  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
458 }
459 
467 static inline int scsw_cmd_is_valid_alcc(union scsw *scsw)
468 {
469  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
470 }
471 
479 static inline int scsw_cmd_is_valid_ssi(union scsw *scsw)
480 {
481  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
482 }
483 
491 static inline int scsw_cmd_is_valid_zcc(union scsw *scsw)
492 {
493  return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
494  (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS);
495 }
496 
504 static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
505 {
506  return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
507  !(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
508  (scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS);
509 }
510 
518 static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
519 {
520  return (scsw->cmd.fctl != 0) &&
521  (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
522  (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) ||
523  ((scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
524  (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)));
525 }
526 
534 static inline int scsw_cmd_is_valid_fctl(union scsw *scsw)
535 {
536  /* Only valid if pmcw.dnv == 1*/
537  return 1;
538 }
539 
547 static inline int scsw_cmd_is_valid_actl(union scsw *scsw)
548 {
549  /* Only valid if pmcw.dnv == 1*/
550  return 1;
551 }
552 
560 static inline int scsw_cmd_is_valid_stctl(union scsw *scsw)
561 {
562  /* Only valid if pmcw.dnv == 1*/
563  return 1;
564 }
565 
573 static inline int scsw_cmd_is_valid_dstat(union scsw *scsw)
574 {
575  return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
576  (scsw->cmd.cc != 3);
577 }
578 
586 static inline int scsw_cmd_is_valid_cstat(union scsw *scsw)
587 {
588  return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
589  (scsw->cmd.cc != 3);
590 }
591 
599 static inline int scsw_tm_is_valid_key(union scsw *scsw)
600 {
601  return (scsw->tm.fctl & SCSW_FCTL_START_FUNC);
602 }
603 
611 static inline int scsw_tm_is_valid_eswf(union scsw *scsw)
612 {
613  return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
614 }
615 
623 static inline int scsw_tm_is_valid_cc(union scsw *scsw)
624 {
625  return (scsw->tm.fctl & SCSW_FCTL_START_FUNC) &&
626  (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
627 }
628 
636 static inline int scsw_tm_is_valid_fmt(union scsw *scsw)
637 {
638  return 1;
639 }
640 
648 static inline int scsw_tm_is_valid_x(union scsw *scsw)
649 {
650  return 1;
651 }
652 
660 static inline int scsw_tm_is_valid_q(union scsw *scsw)
661 {
662  return 1;
663 }
664 
672 static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
673 {
674  return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
675  !(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
676  (scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS);
677 }
678 
686 static inline int scsw_tm_is_valid_pno(union scsw *scsw)
687 {
688  return (scsw->tm.fctl != 0) &&
689  (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
690  (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) ||
691  ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
692  (scsw->tm.actl & SCSW_ACTL_SUSPENDED)));
693 }
694 
702 static inline int scsw_tm_is_valid_fctl(union scsw *scsw)
703 {
704  /* Only valid if pmcw.dnv == 1*/
705  return 1;
706 }
707 
715 static inline int scsw_tm_is_valid_actl(union scsw *scsw)
716 {
717  /* Only valid if pmcw.dnv == 1*/
718  return 1;
719 }
720 
728 static inline int scsw_tm_is_valid_stctl(union scsw *scsw)
729 {
730  /* Only valid if pmcw.dnv == 1*/
731  return 1;
732 }
733 
741 static inline int scsw_tm_is_valid_dstat(union scsw *scsw)
742 {
743  return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
744  (scsw->tm.cc != 3);
745 }
746 
754 static inline int scsw_tm_is_valid_cstat(union scsw *scsw)
755 {
756  return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
757  (scsw->tm.cc != 3);
758 }
759 
767 static inline int scsw_tm_is_valid_fcxs(union scsw *scsw)
768 {
769  return 1;
770 }
771 
779 static inline int scsw_tm_is_valid_schxs(union scsw *scsw)
780 {
781  return (scsw->tm.cstat & (SCHN_STAT_PROG_CHECK |
785 }
786 
795 static inline int scsw_is_valid_actl(union scsw *scsw)
796 {
797  if (scsw_is_tm(scsw))
798  return scsw_tm_is_valid_actl(scsw);
799  else
800  return scsw_cmd_is_valid_actl(scsw);
801 }
802 
811 static inline int scsw_is_valid_cc(union scsw *scsw)
812 {
813  if (scsw_is_tm(scsw))
814  return scsw_tm_is_valid_cc(scsw);
815  else
816  return scsw_cmd_is_valid_cc(scsw);
817 }
818 
827 static inline int scsw_is_valid_cstat(union scsw *scsw)
828 {
829  if (scsw_is_tm(scsw))
830  return scsw_tm_is_valid_cstat(scsw);
831  else
832  return scsw_cmd_is_valid_cstat(scsw);
833 }
834 
843 static inline int scsw_is_valid_dstat(union scsw *scsw)
844 {
845  if (scsw_is_tm(scsw))
846  return scsw_tm_is_valid_dstat(scsw);
847  else
848  return scsw_cmd_is_valid_dstat(scsw);
849 }
850 
859 static inline int scsw_is_valid_ectl(union scsw *scsw)
860 {
861  if (scsw_is_tm(scsw))
862  return scsw_tm_is_valid_ectl(scsw);
863  else
864  return scsw_cmd_is_valid_ectl(scsw);
865 }
866 
875 static inline int scsw_is_valid_eswf(union scsw *scsw)
876 {
877  if (scsw_is_tm(scsw))
878  return scsw_tm_is_valid_eswf(scsw);
879  else
880  return scsw_cmd_is_valid_eswf(scsw);
881 }
882 
891 static inline int scsw_is_valid_fctl(union scsw *scsw)
892 {
893  if (scsw_is_tm(scsw))
894  return scsw_tm_is_valid_fctl(scsw);
895  else
896  return scsw_cmd_is_valid_fctl(scsw);
897 }
898 
907 static inline int scsw_is_valid_key(union scsw *scsw)
908 {
909  if (scsw_is_tm(scsw))
910  return scsw_tm_is_valid_key(scsw);
911  else
912  return scsw_cmd_is_valid_key(scsw);
913 }
914 
923 static inline int scsw_is_valid_pno(union scsw *scsw)
924 {
925  if (scsw_is_tm(scsw))
926  return scsw_tm_is_valid_pno(scsw);
927  else
928  return scsw_cmd_is_valid_pno(scsw);
929 }
930 
939 static inline int scsw_is_valid_stctl(union scsw *scsw)
940 {
941  if (scsw_is_tm(scsw))
942  return scsw_tm_is_valid_stctl(scsw);
943  else
944  return scsw_cmd_is_valid_stctl(scsw);
945 }
946 
954 static inline int scsw_cmd_is_solicited(union scsw *scsw)
955 {
956  return (scsw->cmd.cc != 0) || (scsw->cmd.stctl !=
958 }
959 
967 static inline int scsw_tm_is_solicited(union scsw *scsw)
968 {
969  return (scsw->tm.cc != 0) || (scsw->tm.stctl !=
971 }
972 
980 static inline int scsw_is_solicited(union scsw *scsw)
981 {
982  if (scsw_is_tm(scsw))
983  return scsw_tm_is_solicited(scsw);
984  else
985  return scsw_cmd_is_solicited(scsw);
986 }
987 
988 #endif /* _ASM_S390_SCSW_H_ */