Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Helper functions for scsw access.
0004  *
0005  *    Copyright IBM Corp. 2008, 2012
0006  *    Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
0007  */
0008 
0009 #ifndef _ASM_S390_SCSW_H_
0010 #define _ASM_S390_SCSW_H_
0011 
0012 #include <linux/types.h>
0013 #include <asm/css_chars.h>
0014 #include <asm/cio.h>
0015 
0016 /**
0017  * struct cmd_scsw - command-mode subchannel status word
0018  * @key: subchannel key
0019  * @sctl: suspend control
0020  * @eswf: esw format
0021  * @cc: deferred condition code
0022  * @fmt: format
0023  * @pfch: prefetch
0024  * @isic: initial-status interruption control
0025  * @alcc: address-limit checking control
0026  * @ssi: suppress-suspended interruption
0027  * @zcc: zero condition code
0028  * @ectl: extended control
0029  * @pno: path not operational
0030  * @res: reserved
0031  * @fctl: function control
0032  * @actl: activity control
0033  * @stctl: status control
0034  * @cpa: channel program address
0035  * @dstat: device status
0036  * @cstat: subchannel status
0037  * @count: residual count
0038  */
0039 struct cmd_scsw {
0040     __u32 key  : 4;
0041     __u32 sctl : 1;
0042     __u32 eswf : 1;
0043     __u32 cc   : 2;
0044     __u32 fmt  : 1;
0045     __u32 pfch : 1;
0046     __u32 isic : 1;
0047     __u32 alcc : 1;
0048     __u32 ssi  : 1;
0049     __u32 zcc  : 1;
0050     __u32 ectl : 1;
0051     __u32 pno  : 1;
0052     __u32 res  : 1;
0053     __u32 fctl : 3;
0054     __u32 actl : 7;
0055     __u32 stctl : 5;
0056     __u32 cpa;
0057     __u32 dstat : 8;
0058     __u32 cstat : 8;
0059     __u32 count : 16;
0060 } __attribute__ ((packed));
0061 
0062 /**
0063  * struct tm_scsw - transport-mode subchannel status word
0064  * @key: subchannel key
0065  * @eswf: esw format
0066  * @cc: deferred condition code
0067  * @fmt: format
0068  * @x: IRB-format control
0069  * @q: interrogate-complete
0070  * @ectl: extended control
0071  * @pno: path not operational
0072  * @fctl: function control
0073  * @actl: activity control
0074  * @stctl: status control
0075  * @tcw: TCW address
0076  * @dstat: device status
0077  * @cstat: subchannel status
0078  * @fcxs: FCX status
0079  * @schxs: subchannel-extended status
0080  */
0081 struct tm_scsw {
0082     u32 key:4;
0083     u32 :1;
0084     u32 eswf:1;
0085     u32 cc:2;
0086     u32 fmt:3;
0087     u32 x:1;
0088     u32 q:1;
0089     u32 :1;
0090     u32 ectl:1;
0091     u32 pno:1;
0092     u32 :1;
0093     u32 fctl:3;
0094     u32 actl:7;
0095     u32 stctl:5;
0096     u32 tcw;
0097     u32 dstat:8;
0098     u32 cstat:8;
0099     u32 fcxs:8;
0100     u32 ifob:1;
0101     u32 sesq:7;
0102 } __attribute__ ((packed));
0103 
0104 /**
0105  * struct eadm_scsw - subchannel status word for eadm subchannels
0106  * @key: subchannel key
0107  * @eswf: esw format
0108  * @cc: deferred condition code
0109  * @ectl: extended control
0110  * @fctl: function control
0111  * @actl: activity control
0112  * @stctl: status control
0113  * @aob: AOB address
0114  * @dstat: device status
0115  * @cstat: subchannel status
0116  */
0117 struct eadm_scsw {
0118     u32 key:4;
0119     u32:1;
0120     u32 eswf:1;
0121     u32 cc:2;
0122     u32:6;
0123     u32 ectl:1;
0124     u32:2;
0125     u32 fctl:3;
0126     u32 actl:7;
0127     u32 stctl:5;
0128     u32 aob;
0129     u32 dstat:8;
0130     u32 cstat:8;
0131     u32:16;
0132 } __packed;
0133 
0134 /**
0135  * union scsw - subchannel status word
0136  * @cmd: command-mode SCSW
0137  * @tm: transport-mode SCSW
0138  * @eadm: eadm SCSW
0139  */
0140 union scsw {
0141     struct cmd_scsw cmd;
0142     struct tm_scsw tm;
0143     struct eadm_scsw eadm;
0144 } __packed;
0145 
0146 #define SCSW_FCTL_CLEAR_FUNC     0x1
0147 #define SCSW_FCTL_HALT_FUNC  0x2
0148 #define SCSW_FCTL_START_FUNC     0x4
0149 
0150 #define SCSW_ACTL_SUSPENDED  0x1
0151 #define SCSW_ACTL_DEVACT     0x2
0152 #define SCSW_ACTL_SCHACT     0x4
0153 #define SCSW_ACTL_CLEAR_PEND     0x8
0154 #define SCSW_ACTL_HALT_PEND  0x10
0155 #define SCSW_ACTL_START_PEND     0x20
0156 #define SCSW_ACTL_RESUME_PEND    0x40
0157 
0158 #define SCSW_STCTL_STATUS_PEND   0x1
0159 #define SCSW_STCTL_SEC_STATUS    0x2
0160 #define SCSW_STCTL_PRIM_STATUS   0x4
0161 #define SCSW_STCTL_INTER_STATUS  0x8
0162 #define SCSW_STCTL_ALERT_STATUS  0x10
0163 
0164 #define DEV_STAT_ATTENTION   0x80
0165 #define DEV_STAT_STAT_MOD    0x40
0166 #define DEV_STAT_CU_END      0x20
0167 #define DEV_STAT_BUSY        0x10
0168 #define DEV_STAT_CHN_END     0x08
0169 #define DEV_STAT_DEV_END     0x04
0170 #define DEV_STAT_UNIT_CHECK  0x02
0171 #define DEV_STAT_UNIT_EXCEP  0x01
0172 
0173 #define SCHN_STAT_PCI        0x80
0174 #define SCHN_STAT_INCORR_LEN     0x40
0175 #define SCHN_STAT_PROG_CHECK     0x20
0176 #define SCHN_STAT_PROT_CHECK     0x10
0177 #define SCHN_STAT_CHN_DATA_CHK   0x08
0178 #define SCHN_STAT_CHN_CTRL_CHK   0x04
0179 #define SCHN_STAT_INTF_CTRL_CHK  0x02
0180 #define SCHN_STAT_CHAIN_CHECK    0x01
0181 
0182 #define SCSW_SESQ_DEV_NOFCX  3
0183 #define SCSW_SESQ_PATH_NOFCX     4
0184 
0185 /*
0186  * architectured values for first sense byte
0187  */
0188 #define SNS0_CMD_REJECT     0x80
0189 #define SNS_CMD_REJECT      SNS0_CMD_REJEC
0190 #define SNS0_INTERVENTION_REQ   0x40
0191 #define SNS0_BUS_OUT_CHECK  0x20
0192 #define SNS0_EQUIPMENT_CHECK    0x10
0193 #define SNS0_DATA_CHECK     0x08
0194 #define SNS0_OVERRUN        0x04
0195 #define SNS0_INCOMPL_DOMAIN 0x01
0196 
0197 /*
0198  * architectured values for second sense byte
0199  */
0200 #define SNS1_PERM_ERR       0x80
0201 #define SNS1_INV_TRACK_FORMAT   0x40
0202 #define SNS1_EOC        0x20
0203 #define SNS1_MESSAGE_TO_OPER    0x10
0204 #define SNS1_NO_REC_FOUND   0x08
0205 #define SNS1_FILE_PROTECTED 0x04
0206 #define SNS1_WRITE_INHIBITED    0x02
0207 #define SNS1_INPRECISE_END  0x01
0208 
0209 /*
0210  * architectured values for third sense byte
0211  */
0212 #define SNS2_REQ_INH_WRITE  0x80
0213 #define SNS2_CORRECTABLE    0x40
0214 #define SNS2_FIRST_LOG_ERR  0x20
0215 #define SNS2_ENV_DATA_PRESENT   0x10
0216 #define SNS2_INPRECISE_END  0x04
0217 
0218 /**
0219  * scsw_is_tm - check for transport mode scsw
0220  * @scsw: pointer to scsw
0221  *
0222  * Return non-zero if the specified scsw is a transport mode scsw, zero
0223  * otherwise.
0224  */
0225 static inline int scsw_is_tm(union scsw *scsw)
0226 {
0227     return css_general_characteristics.fcx && (scsw->tm.x == 1);
0228 }
0229 
0230 /**
0231  * scsw_key - return scsw key field
0232  * @scsw: pointer to scsw
0233  *
0234  * Return the value of the key field of the specified scsw, regardless of
0235  * whether it is a transport mode or command mode scsw.
0236  */
0237 static inline u32 scsw_key(union scsw *scsw)
0238 {
0239     if (scsw_is_tm(scsw))
0240         return scsw->tm.key;
0241     else
0242         return scsw->cmd.key;
0243 }
0244 
0245 /**
0246  * scsw_eswf - return scsw eswf field
0247  * @scsw: pointer to scsw
0248  *
0249  * Return the value of the eswf field of the specified scsw, regardless of
0250  * whether it is a transport mode or command mode scsw.
0251  */
0252 static inline u32 scsw_eswf(union scsw *scsw)
0253 {
0254     if (scsw_is_tm(scsw))
0255         return scsw->tm.eswf;
0256     else
0257         return scsw->cmd.eswf;
0258 }
0259 
0260 /**
0261  * scsw_cc - return scsw cc field
0262  * @scsw: pointer to scsw
0263  *
0264  * Return the value of the cc field of the specified scsw, regardless of
0265  * whether it is a transport mode or command mode scsw.
0266  */
0267 static inline u32 scsw_cc(union scsw *scsw)
0268 {
0269     if (scsw_is_tm(scsw))
0270         return scsw->tm.cc;
0271     else
0272         return scsw->cmd.cc;
0273 }
0274 
0275 /**
0276  * scsw_ectl - return scsw ectl field
0277  * @scsw: pointer to scsw
0278  *
0279  * Return the value of the ectl field of the specified scsw, regardless of
0280  * whether it is a transport mode or command mode scsw.
0281  */
0282 static inline u32 scsw_ectl(union scsw *scsw)
0283 {
0284     if (scsw_is_tm(scsw))
0285         return scsw->tm.ectl;
0286     else
0287         return scsw->cmd.ectl;
0288 }
0289 
0290 /**
0291  * scsw_pno - return scsw pno field
0292  * @scsw: pointer to scsw
0293  *
0294  * Return the value of the pno field of the specified scsw, regardless of
0295  * whether it is a transport mode or command mode scsw.
0296  */
0297 static inline u32 scsw_pno(union scsw *scsw)
0298 {
0299     if (scsw_is_tm(scsw))
0300         return scsw->tm.pno;
0301     else
0302         return scsw->cmd.pno;
0303 }
0304 
0305 /**
0306  * scsw_fctl - return scsw fctl field
0307  * @scsw: pointer to scsw
0308  *
0309  * Return the value of the fctl field of the specified scsw, regardless of
0310  * whether it is a transport mode or command mode scsw.
0311  */
0312 static inline u32 scsw_fctl(union scsw *scsw)
0313 {
0314     if (scsw_is_tm(scsw))
0315         return scsw->tm.fctl;
0316     else
0317         return scsw->cmd.fctl;
0318 }
0319 
0320 /**
0321  * scsw_actl - return scsw actl field
0322  * @scsw: pointer to scsw
0323  *
0324  * Return the value of the actl field of the specified scsw, regardless of
0325  * whether it is a transport mode or command mode scsw.
0326  */
0327 static inline u32 scsw_actl(union scsw *scsw)
0328 {
0329     if (scsw_is_tm(scsw))
0330         return scsw->tm.actl;
0331     else
0332         return scsw->cmd.actl;
0333 }
0334 
0335 /**
0336  * scsw_stctl - return scsw stctl field
0337  * @scsw: pointer to scsw
0338  *
0339  * Return the value of the stctl field of the specified scsw, regardless of
0340  * whether it is a transport mode or command mode scsw.
0341  */
0342 static inline u32 scsw_stctl(union scsw *scsw)
0343 {
0344     if (scsw_is_tm(scsw))
0345         return scsw->tm.stctl;
0346     else
0347         return scsw->cmd.stctl;
0348 }
0349 
0350 /**
0351  * scsw_dstat - return scsw dstat field
0352  * @scsw: pointer to scsw
0353  *
0354  * Return the value of the dstat field of the specified scsw, regardless of
0355  * whether it is a transport mode or command mode scsw.
0356  */
0357 static inline u32 scsw_dstat(union scsw *scsw)
0358 {
0359     if (scsw_is_tm(scsw))
0360         return scsw->tm.dstat;
0361     else
0362         return scsw->cmd.dstat;
0363 }
0364 
0365 /**
0366  * scsw_cstat - return scsw cstat field
0367  * @scsw: pointer to scsw
0368  *
0369  * Return the value of the cstat field of the specified scsw, regardless of
0370  * whether it is a transport mode or command mode scsw.
0371  */
0372 static inline u32 scsw_cstat(union scsw *scsw)
0373 {
0374     if (scsw_is_tm(scsw))
0375         return scsw->tm.cstat;
0376     else
0377         return scsw->cmd.cstat;
0378 }
0379 
0380 /**
0381  * scsw_cmd_is_valid_key - check key field validity
0382  * @scsw: pointer to scsw
0383  *
0384  * Return non-zero if the key field of the specified command mode scsw is
0385  * valid, zero otherwise.
0386  */
0387 static inline int scsw_cmd_is_valid_key(union scsw *scsw)
0388 {
0389     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0390 }
0391 
0392 /**
0393  * scsw_cmd_is_valid_sctl - check sctl field validity
0394  * @scsw: pointer to scsw
0395  *
0396  * Return non-zero if the sctl field of the specified command mode scsw is
0397  * valid, zero otherwise.
0398  */
0399 static inline int scsw_cmd_is_valid_sctl(union scsw *scsw)
0400 {
0401     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0402 }
0403 
0404 /**
0405  * scsw_cmd_is_valid_eswf - check eswf field validity
0406  * @scsw: pointer to scsw
0407  *
0408  * Return non-zero if the eswf field of the specified command mode scsw is
0409  * valid, zero otherwise.
0410  */
0411 static inline int scsw_cmd_is_valid_eswf(union scsw *scsw)
0412 {
0413     return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
0414 }
0415 
0416 /**
0417  * scsw_cmd_is_valid_cc - check cc field validity
0418  * @scsw: pointer to scsw
0419  *
0420  * Return non-zero if the cc field of the specified command mode scsw is
0421  * valid, zero otherwise.
0422  */
0423 static inline int scsw_cmd_is_valid_cc(union scsw *scsw)
0424 {
0425     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
0426            (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
0427 }
0428 
0429 /**
0430  * scsw_cmd_is_valid_fmt - check fmt field validity
0431  * @scsw: pointer to scsw
0432  *
0433  * Return non-zero if the fmt field of the specified command mode scsw is
0434  * valid, zero otherwise.
0435  */
0436 static inline int scsw_cmd_is_valid_fmt(union scsw *scsw)
0437 {
0438     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0439 }
0440 
0441 /**
0442  * scsw_cmd_is_valid_pfch - check pfch field validity
0443  * @scsw: pointer to scsw
0444  *
0445  * Return non-zero if the pfch field of the specified command mode scsw is
0446  * valid, zero otherwise.
0447  */
0448 static inline int scsw_cmd_is_valid_pfch(union scsw *scsw)
0449 {
0450     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0451 }
0452 
0453 /**
0454  * scsw_cmd_is_valid_isic - check isic field validity
0455  * @scsw: pointer to scsw
0456  *
0457  * Return non-zero if the isic field of the specified command mode scsw is
0458  * valid, zero otherwise.
0459  */
0460 static inline int scsw_cmd_is_valid_isic(union scsw *scsw)
0461 {
0462     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0463 }
0464 
0465 /**
0466  * scsw_cmd_is_valid_alcc - check alcc field validity
0467  * @scsw: pointer to scsw
0468  *
0469  * Return non-zero if the alcc field of the specified command mode scsw is
0470  * valid, zero otherwise.
0471  */
0472 static inline int scsw_cmd_is_valid_alcc(union scsw *scsw)
0473 {
0474     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0475 }
0476 
0477 /**
0478  * scsw_cmd_is_valid_ssi - check ssi field validity
0479  * @scsw: pointer to scsw
0480  *
0481  * Return non-zero if the ssi field of the specified command mode scsw is
0482  * valid, zero otherwise.
0483  */
0484 static inline int scsw_cmd_is_valid_ssi(union scsw *scsw)
0485 {
0486     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
0487 }
0488 
0489 /**
0490  * scsw_cmd_is_valid_zcc - check zcc field validity
0491  * @scsw: pointer to scsw
0492  *
0493  * Return non-zero if the zcc field of the specified command mode scsw is
0494  * valid, zero otherwise.
0495  */
0496 static inline int scsw_cmd_is_valid_zcc(union scsw *scsw)
0497 {
0498     return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
0499            (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS);
0500 }
0501 
0502 /**
0503  * scsw_cmd_is_valid_ectl - check ectl field validity
0504  * @scsw: pointer to scsw
0505  *
0506  * Return non-zero if the ectl field of the specified command mode scsw is
0507  * valid, zero otherwise.
0508  */
0509 static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
0510 {
0511     /* Must be status pending. */
0512     if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
0513         return 0;
0514 
0515     /* Must have alert status. */
0516     if (!(scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS))
0517         return 0;
0518 
0519     /* Must be alone or together with primary, secondary or both,
0520      * => no intermediate status.
0521      */
0522     if (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS)
0523         return 0;
0524 
0525     return 1;
0526 }
0527 
0528 /**
0529  * scsw_cmd_is_valid_pno - check pno field validity
0530  * @scsw: pointer to scsw
0531  *
0532  * Return non-zero if the pno field of the specified command mode scsw is
0533  * valid, zero otherwise.
0534  */
0535 static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
0536 {
0537     /* Must indicate at least one I/O function. */
0538     if (!scsw->cmd.fctl)
0539         return 0;
0540 
0541     /* Must be status pending. */
0542     if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
0543         return 0;
0544 
0545     /* Can be status pending alone, or with any combination of primary,
0546      * secondary and alert => no intermediate status.
0547      */
0548     if (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS))
0549         return 1;
0550 
0551     /* If intermediate, must be suspended. */
0552     if (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)
0553         return 1;
0554 
0555     return 0;
0556 }
0557 
0558 /**
0559  * scsw_cmd_is_valid_fctl - check fctl field validity
0560  * @scsw: pointer to scsw
0561  *
0562  * Return non-zero if the fctl field of the specified command mode scsw is
0563  * valid, zero otherwise.
0564  */
0565 static inline int scsw_cmd_is_valid_fctl(union scsw *scsw)
0566 {
0567     /* Only valid if pmcw.dnv == 1*/
0568     return 1;
0569 }
0570 
0571 /**
0572  * scsw_cmd_is_valid_actl - check actl field validity
0573  * @scsw: pointer to scsw
0574  *
0575  * Return non-zero if the actl field of the specified command mode scsw is
0576  * valid, zero otherwise.
0577  */
0578 static inline int scsw_cmd_is_valid_actl(union scsw *scsw)
0579 {
0580     /* Only valid if pmcw.dnv == 1*/
0581     return 1;
0582 }
0583 
0584 /**
0585  * scsw_cmd_is_valid_stctl - check stctl field validity
0586  * @scsw: pointer to scsw
0587  *
0588  * Return non-zero if the stctl field of the specified command mode scsw is
0589  * valid, zero otherwise.
0590  */
0591 static inline int scsw_cmd_is_valid_stctl(union scsw *scsw)
0592 {
0593     /* Only valid if pmcw.dnv == 1*/
0594     return 1;
0595 }
0596 
0597 /**
0598  * scsw_cmd_is_valid_dstat - check dstat field validity
0599  * @scsw: pointer to scsw
0600  *
0601  * Return non-zero if the dstat field of the specified command mode scsw is
0602  * valid, zero otherwise.
0603  */
0604 static inline int scsw_cmd_is_valid_dstat(union scsw *scsw)
0605 {
0606     return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
0607            (scsw->cmd.cc != 3);
0608 }
0609 
0610 /**
0611  * scsw_cmd_is_valid_cstat - check cstat field validity
0612  * @scsw: pointer to scsw
0613  *
0614  * Return non-zero if the cstat field of the specified command mode scsw is
0615  * valid, zero otherwise.
0616  */
0617 static inline int scsw_cmd_is_valid_cstat(union scsw *scsw)
0618 {
0619     return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
0620            (scsw->cmd.cc != 3);
0621 }
0622 
0623 /**
0624  * scsw_tm_is_valid_key - check key field validity
0625  * @scsw: pointer to scsw
0626  *
0627  * Return non-zero if the key field of the specified transport mode scsw is
0628  * valid, zero otherwise.
0629  */
0630 static inline int scsw_tm_is_valid_key(union scsw *scsw)
0631 {
0632     return (scsw->tm.fctl & SCSW_FCTL_START_FUNC);
0633 }
0634 
0635 /**
0636  * scsw_tm_is_valid_eswf - check eswf field validity
0637  * @scsw: pointer to scsw
0638  *
0639  * Return non-zero if the eswf field of the specified transport mode scsw is
0640  * valid, zero otherwise.
0641  */
0642 static inline int scsw_tm_is_valid_eswf(union scsw *scsw)
0643 {
0644     return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
0645 }
0646 
0647 /**
0648  * scsw_tm_is_valid_cc - check cc field validity
0649  * @scsw: pointer to scsw
0650  *
0651  * Return non-zero if the cc field of the specified transport mode scsw is
0652  * valid, zero otherwise.
0653  */
0654 static inline int scsw_tm_is_valid_cc(union scsw *scsw)
0655 {
0656     return (scsw->tm.fctl & SCSW_FCTL_START_FUNC) &&
0657            (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
0658 }
0659 
0660 /**
0661  * scsw_tm_is_valid_fmt - check fmt field validity
0662  * @scsw: pointer to scsw
0663  *
0664  * Return non-zero if the fmt field of the specified transport mode scsw is
0665  * valid, zero otherwise.
0666  */
0667 static inline int scsw_tm_is_valid_fmt(union scsw *scsw)
0668 {
0669     return 1;
0670 }
0671 
0672 /**
0673  * scsw_tm_is_valid_x - check x field validity
0674  * @scsw: pointer to scsw
0675  *
0676  * Return non-zero if the x field of the specified transport mode scsw is
0677  * valid, zero otherwise.
0678  */
0679 static inline int scsw_tm_is_valid_x(union scsw *scsw)
0680 {
0681     return 1;
0682 }
0683 
0684 /**
0685  * scsw_tm_is_valid_q - check q field validity
0686  * @scsw: pointer to scsw
0687  *
0688  * Return non-zero if the q field of the specified transport mode scsw is
0689  * valid, zero otherwise.
0690  */
0691 static inline int scsw_tm_is_valid_q(union scsw *scsw)
0692 {
0693     return 1;
0694 }
0695 
0696 /**
0697  * scsw_tm_is_valid_ectl - check ectl field validity
0698  * @scsw: pointer to scsw
0699  *
0700  * Return non-zero if the ectl field of the specified transport mode scsw is
0701  * valid, zero otherwise.
0702  */
0703 static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
0704 {
0705     /* Must be status pending. */
0706     if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
0707         return 0;
0708 
0709     /* Must have alert status. */
0710     if (!(scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS))
0711         return 0;
0712 
0713     /* Must be alone or together with primary, secondary or both,
0714      * => no intermediate status.
0715      */
0716     if (scsw->tm.stctl & SCSW_STCTL_INTER_STATUS)
0717         return 0;
0718 
0719     return 1;
0720 }
0721 
0722 /**
0723  * scsw_tm_is_valid_pno - check pno field validity
0724  * @scsw: pointer to scsw
0725  *
0726  * Return non-zero if the pno field of the specified transport mode scsw is
0727  * valid, zero otherwise.
0728  */
0729 static inline int scsw_tm_is_valid_pno(union scsw *scsw)
0730 {
0731     /* Must indicate at least one I/O function. */
0732     if (!scsw->tm.fctl)
0733         return 0;
0734 
0735     /* Must be status pending. */
0736     if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
0737         return 0;
0738 
0739     /* Can be status pending alone, or with any combination of primary,
0740      * secondary and alert => no intermediate status.
0741      */
0742     if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
0743         return 1;
0744 
0745     /* If intermediate, must be suspended. */
0746     if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
0747         return 1;
0748 
0749     return 0;
0750 }
0751 
0752 /**
0753  * scsw_tm_is_valid_fctl - check fctl field validity
0754  * @scsw: pointer to scsw
0755  *
0756  * Return non-zero if the fctl field of the specified transport mode scsw is
0757  * valid, zero otherwise.
0758  */
0759 static inline int scsw_tm_is_valid_fctl(union scsw *scsw)
0760 {
0761     /* Only valid if pmcw.dnv == 1*/
0762     return 1;
0763 }
0764 
0765 /**
0766  * scsw_tm_is_valid_actl - check actl field validity
0767  * @scsw: pointer to scsw
0768  *
0769  * Return non-zero if the actl field of the specified transport mode scsw is
0770  * valid, zero otherwise.
0771  */
0772 static inline int scsw_tm_is_valid_actl(union scsw *scsw)
0773 {
0774     /* Only valid if pmcw.dnv == 1*/
0775     return 1;
0776 }
0777 
0778 /**
0779  * scsw_tm_is_valid_stctl - check stctl field validity
0780  * @scsw: pointer to scsw
0781  *
0782  * Return non-zero if the stctl field of the specified transport mode scsw is
0783  * valid, zero otherwise.
0784  */
0785 static inline int scsw_tm_is_valid_stctl(union scsw *scsw)
0786 {
0787     /* Only valid if pmcw.dnv == 1*/
0788     return 1;
0789 }
0790 
0791 /**
0792  * scsw_tm_is_valid_dstat - check dstat field validity
0793  * @scsw: pointer to scsw
0794  *
0795  * Return non-zero if the dstat field of the specified transport mode scsw is
0796  * valid, zero otherwise.
0797  */
0798 static inline int scsw_tm_is_valid_dstat(union scsw *scsw)
0799 {
0800     return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
0801            (scsw->tm.cc != 3);
0802 }
0803 
0804 /**
0805  * scsw_tm_is_valid_cstat - check cstat field validity
0806  * @scsw: pointer to scsw
0807  *
0808  * Return non-zero if the cstat field of the specified transport mode scsw is
0809  * valid, zero otherwise.
0810  */
0811 static inline int scsw_tm_is_valid_cstat(union scsw *scsw)
0812 {
0813     return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
0814            (scsw->tm.cc != 3);
0815 }
0816 
0817 /**
0818  * scsw_tm_is_valid_fcxs - check fcxs field validity
0819  * @scsw: pointer to scsw
0820  *
0821  * Return non-zero if the fcxs field of the specified transport mode scsw is
0822  * valid, zero otherwise.
0823  */
0824 static inline int scsw_tm_is_valid_fcxs(union scsw *scsw)
0825 {
0826     return 1;
0827 }
0828 
0829 /**
0830  * scsw_tm_is_valid_schxs - check schxs field validity
0831  * @scsw: pointer to scsw
0832  *
0833  * Return non-zero if the schxs field of the specified transport mode scsw is
0834  * valid, zero otherwise.
0835  */
0836 static inline int scsw_tm_is_valid_schxs(union scsw *scsw)
0837 {
0838     return (scsw->tm.cstat & (SCHN_STAT_PROG_CHECK |
0839                   SCHN_STAT_INTF_CTRL_CHK |
0840                   SCHN_STAT_PROT_CHECK |
0841                   SCHN_STAT_CHN_DATA_CHK));
0842 }
0843 
0844 /**
0845  * scsw_is_valid_actl - check actl field validity
0846  * @scsw: pointer to scsw
0847  *
0848  * Return non-zero if the actl field of the specified scsw is valid,
0849  * regardless of whether it is a transport mode or command mode scsw.
0850  * Return zero if the field does not contain a valid value.
0851  */
0852 static inline int scsw_is_valid_actl(union scsw *scsw)
0853 {
0854     if (scsw_is_tm(scsw))
0855         return scsw_tm_is_valid_actl(scsw);
0856     else
0857         return scsw_cmd_is_valid_actl(scsw);
0858 }
0859 
0860 /**
0861  * scsw_is_valid_cc - check cc field validity
0862  * @scsw: pointer to scsw
0863  *
0864  * Return non-zero if the cc field of the specified scsw is valid,
0865  * regardless of whether it is a transport mode or command mode scsw.
0866  * Return zero if the field does not contain a valid value.
0867  */
0868 static inline int scsw_is_valid_cc(union scsw *scsw)
0869 {
0870     if (scsw_is_tm(scsw))
0871         return scsw_tm_is_valid_cc(scsw);
0872     else
0873         return scsw_cmd_is_valid_cc(scsw);
0874 }
0875 
0876 /**
0877  * scsw_is_valid_cstat - check cstat field validity
0878  * @scsw: pointer to scsw
0879  *
0880  * Return non-zero if the cstat field of the specified scsw is valid,
0881  * regardless of whether it is a transport mode or command mode scsw.
0882  * Return zero if the field does not contain a valid value.
0883  */
0884 static inline int scsw_is_valid_cstat(union scsw *scsw)
0885 {
0886     if (scsw_is_tm(scsw))
0887         return scsw_tm_is_valid_cstat(scsw);
0888     else
0889         return scsw_cmd_is_valid_cstat(scsw);
0890 }
0891 
0892 /**
0893  * scsw_is_valid_dstat - check dstat field validity
0894  * @scsw: pointer to scsw
0895  *
0896  * Return non-zero if the dstat field of the specified scsw is valid,
0897  * regardless of whether it is a transport mode or command mode scsw.
0898  * Return zero if the field does not contain a valid value.
0899  */
0900 static inline int scsw_is_valid_dstat(union scsw *scsw)
0901 {
0902     if (scsw_is_tm(scsw))
0903         return scsw_tm_is_valid_dstat(scsw);
0904     else
0905         return scsw_cmd_is_valid_dstat(scsw);
0906 }
0907 
0908 /**
0909  * scsw_is_valid_ectl - check ectl field validity
0910  * @scsw: pointer to scsw
0911  *
0912  * Return non-zero if the ectl field of the specified scsw is valid,
0913  * regardless of whether it is a transport mode or command mode scsw.
0914  * Return zero if the field does not contain a valid value.
0915  */
0916 static inline int scsw_is_valid_ectl(union scsw *scsw)
0917 {
0918     if (scsw_is_tm(scsw))
0919         return scsw_tm_is_valid_ectl(scsw);
0920     else
0921         return scsw_cmd_is_valid_ectl(scsw);
0922 }
0923 
0924 /**
0925  * scsw_is_valid_eswf - check eswf field validity
0926  * @scsw: pointer to scsw
0927  *
0928  * Return non-zero if the eswf field of the specified scsw is valid,
0929  * regardless of whether it is a transport mode or command mode scsw.
0930  * Return zero if the field does not contain a valid value.
0931  */
0932 static inline int scsw_is_valid_eswf(union scsw *scsw)
0933 {
0934     if (scsw_is_tm(scsw))
0935         return scsw_tm_is_valid_eswf(scsw);
0936     else
0937         return scsw_cmd_is_valid_eswf(scsw);
0938 }
0939 
0940 /**
0941  * scsw_is_valid_fctl - check fctl field validity
0942  * @scsw: pointer to scsw
0943  *
0944  * Return non-zero if the fctl field of the specified scsw is valid,
0945  * regardless of whether it is a transport mode or command mode scsw.
0946  * Return zero if the field does not contain a valid value.
0947  */
0948 static inline int scsw_is_valid_fctl(union scsw *scsw)
0949 {
0950     if (scsw_is_tm(scsw))
0951         return scsw_tm_is_valid_fctl(scsw);
0952     else
0953         return scsw_cmd_is_valid_fctl(scsw);
0954 }
0955 
0956 /**
0957  * scsw_is_valid_key - check key field validity
0958  * @scsw: pointer to scsw
0959  *
0960  * Return non-zero if the key field of the specified scsw is valid,
0961  * regardless of whether it is a transport mode or command mode scsw.
0962  * Return zero if the field does not contain a valid value.
0963  */
0964 static inline int scsw_is_valid_key(union scsw *scsw)
0965 {
0966     if (scsw_is_tm(scsw))
0967         return scsw_tm_is_valid_key(scsw);
0968     else
0969         return scsw_cmd_is_valid_key(scsw);
0970 }
0971 
0972 /**
0973  * scsw_is_valid_pno - check pno field validity
0974  * @scsw: pointer to scsw
0975  *
0976  * Return non-zero if the pno field of the specified scsw is valid,
0977  * regardless of whether it is a transport mode or command mode scsw.
0978  * Return zero if the field does not contain a valid value.
0979  */
0980 static inline int scsw_is_valid_pno(union scsw *scsw)
0981 {
0982     if (scsw_is_tm(scsw))
0983         return scsw_tm_is_valid_pno(scsw);
0984     else
0985         return scsw_cmd_is_valid_pno(scsw);
0986 }
0987 
0988 /**
0989  * scsw_is_valid_stctl - check stctl field validity
0990  * @scsw: pointer to scsw
0991  *
0992  * Return non-zero if the stctl field of the specified scsw is valid,
0993  * regardless of whether it is a transport mode or command mode scsw.
0994  * Return zero if the field does not contain a valid value.
0995  */
0996 static inline int scsw_is_valid_stctl(union scsw *scsw)
0997 {
0998     if (scsw_is_tm(scsw))
0999         return scsw_tm_is_valid_stctl(scsw);
1000     else
1001         return scsw_cmd_is_valid_stctl(scsw);
1002 }
1003 
1004 /**
1005  * scsw_cmd_is_solicited - check for solicited scsw
1006  * @scsw: pointer to scsw
1007  *
1008  * Return non-zero if the command mode scsw indicates that the associated
1009  * status condition is solicited, zero if it is unsolicited.
1010  */
1011 static inline int scsw_cmd_is_solicited(union scsw *scsw)
1012 {
1013     return (scsw->cmd.cc != 0) || (scsw->cmd.stctl !=
1014         (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
1015 }
1016 
1017 /**
1018  * scsw_tm_is_solicited - check for solicited scsw
1019  * @scsw: pointer to scsw
1020  *
1021  * Return non-zero if the transport mode scsw indicates that the associated
1022  * status condition is solicited, zero if it is unsolicited.
1023  */
1024 static inline int scsw_tm_is_solicited(union scsw *scsw)
1025 {
1026     return (scsw->tm.cc != 0) || (scsw->tm.stctl !=
1027         (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
1028 }
1029 
1030 /**
1031  * scsw_is_solicited - check for solicited scsw
1032  * @scsw: pointer to scsw
1033  *
1034  * Return non-zero if the transport or command mode scsw indicates that the
1035  * associated status condition is solicited, zero if it is unsolicited.
1036  */
1037 static inline int scsw_is_solicited(union scsw *scsw)
1038 {
1039     if (scsw_is_tm(scsw))
1040         return scsw_tm_is_solicited(scsw);
1041     else
1042         return scsw_cmd_is_solicited(scsw);
1043 }
1044 
1045 #endif /* _ASM_S390_SCSW_H_ */