Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Common interface for I/O on S/390
0004  */
0005 #ifndef _ASM_S390_CIO_H_
0006 #define _ASM_S390_CIO_H_
0007 
0008 #include <linux/bitops.h>
0009 #include <linux/genalloc.h>
0010 #include <asm/types.h>
0011 #include <asm/tpi.h>
0012 
0013 #define LPM_ANYPATH 0xff
0014 #define __MAX_CSSID 0
0015 #define __MAX_SUBCHANNEL 65535
0016 #define __MAX_SSID 3
0017 
0018 #include <asm/scsw.h>
0019 
0020 /**
0021  * struct ccw1 - channel command word
0022  * @cmd_code: command code
0023  * @flags: flags, like IDA addressing, etc.
0024  * @count: byte count
0025  * @cda: data address
0026  *
0027  * The ccw is the basic structure to build channel programs that perform
0028  * operations with the device or the control unit. Only Format-1 channel
0029  * command words are supported.
0030  */
0031 struct ccw1 {
0032     __u8  cmd_code;
0033     __u8  flags;
0034     __u16 count;
0035     __u32 cda;
0036 } __attribute__ ((packed,aligned(8)));
0037 
0038 /**
0039  * struct ccw0 - channel command word
0040  * @cmd_code: command code
0041  * @cda: data address
0042  * @flags: flags, like IDA addressing, etc.
0043  * @reserved: will be ignored
0044  * @count: byte count
0045  *
0046  * The format-0 ccw structure.
0047  */
0048 struct ccw0 {
0049     __u8 cmd_code;
0050     __u32 cda : 24;
0051     __u8  flags;
0052     __u8  reserved;
0053     __u16 count;
0054 } __packed __aligned(8);
0055 
0056 #define CCW_FLAG_DC     0x80
0057 #define CCW_FLAG_CC     0x40
0058 #define CCW_FLAG_SLI        0x20
0059 #define CCW_FLAG_SKIP       0x10
0060 #define CCW_FLAG_PCI        0x08
0061 #define CCW_FLAG_IDA        0x04
0062 #define CCW_FLAG_SUSPEND    0x02
0063 
0064 #define CCW_CMD_READ_IPL    0x02
0065 #define CCW_CMD_NOOP        0x03
0066 #define CCW_CMD_BASIC_SENSE 0x04
0067 #define CCW_CMD_TIC     0x08
0068 #define CCW_CMD_STLCK           0x14
0069 #define CCW_CMD_SENSE_PGID  0x34
0070 #define CCW_CMD_SUSPEND_RECONN  0x5B
0071 #define CCW_CMD_RDC     0x64
0072 #define CCW_CMD_RELEASE     0x94
0073 #define CCW_CMD_SET_PGID    0xAF
0074 #define CCW_CMD_SENSE_ID    0xE4
0075 #define CCW_CMD_DCTL        0xF3
0076 
0077 #define SENSE_MAX_COUNT     0x20
0078 
0079 /**
0080  * struct erw - extended report word
0081  * @res0: reserved
0082  * @auth: authorization check
0083  * @pvrf: path-verification-required flag
0084  * @cpt: channel-path timeout
0085  * @fsavf: failing storage address validity flag
0086  * @cons: concurrent sense
0087  * @scavf: secondary ccw address validity flag
0088  * @fsaf: failing storage address format
0089  * @scnt: sense count, if @cons == %1
0090  * @res16: reserved
0091  */
0092 struct erw {
0093     __u32 res0  : 3;
0094     __u32 auth  : 1;
0095     __u32 pvrf  : 1;
0096     __u32 cpt   : 1;
0097     __u32 fsavf : 1;
0098     __u32 cons  : 1;
0099     __u32 scavf : 1;
0100     __u32 fsaf  : 1;
0101     __u32 scnt  : 6;
0102     __u32 res16 : 16;
0103 } __attribute__ ((packed));
0104 
0105 /**
0106  * struct erw_eadm - EADM Subchannel extended report word
0107  * @b: aob error
0108  * @r: arsb error
0109  */
0110 struct erw_eadm {
0111     __u32 : 16;
0112     __u32 b : 1;
0113     __u32 r : 1;
0114     __u32  : 14;
0115 } __packed;
0116 
0117 /**
0118  * struct sublog - subchannel logout area
0119  * @res0: reserved
0120  * @esf: extended status flags
0121  * @lpum: last path used mask
0122  * @arep: ancillary report
0123  * @fvf: field-validity flags
0124  * @sacc: storage access code
0125  * @termc: termination code
0126  * @devsc: device-status check
0127  * @serr: secondary error
0128  * @ioerr: i/o-error alert
0129  * @seqc: sequence code
0130  */
0131 struct sublog {
0132     __u32 res0  : 1;
0133     __u32 esf   : 7;
0134     __u32 lpum  : 8;
0135     __u32 arep  : 1;
0136     __u32 fvf   : 5;
0137     __u32 sacc  : 2;
0138     __u32 termc : 2;
0139     __u32 devsc : 1;
0140     __u32 serr  : 1;
0141     __u32 ioerr : 1;
0142     __u32 seqc  : 3;
0143 } __attribute__ ((packed));
0144 
0145 /**
0146  * struct esw0 - Format 0 Extended Status Word (ESW)
0147  * @sublog: subchannel logout
0148  * @erw: extended report word
0149  * @faddr: failing storage address
0150  * @saddr: secondary ccw address
0151  */
0152 struct esw0 {
0153     struct sublog sublog;
0154     struct erw erw;
0155     __u32  faddr[2];
0156     __u32  saddr;
0157 } __attribute__ ((packed));
0158 
0159 /**
0160  * struct esw1 - Format 1 Extended Status Word (ESW)
0161  * @zero0: reserved zeros
0162  * @lpum: last path used mask
0163  * @zero16: reserved zeros
0164  * @erw: extended report word
0165  * @zeros: three fullwords of zeros
0166  */
0167 struct esw1 {
0168     __u8  zero0;
0169     __u8  lpum;
0170     __u16 zero16;
0171     struct erw erw;
0172     __u32 zeros[3];
0173 } __attribute__ ((packed));
0174 
0175 /**
0176  * struct esw2 - Format 2 Extended Status Word (ESW)
0177  * @zero0: reserved zeros
0178  * @lpum: last path used mask
0179  * @dcti: device-connect-time interval
0180  * @erw: extended report word
0181  * @zeros: three fullwords of zeros
0182  */
0183 struct esw2 {
0184     __u8  zero0;
0185     __u8  lpum;
0186     __u16 dcti;
0187     struct erw erw;
0188     __u32 zeros[3];
0189 } __attribute__ ((packed));
0190 
0191 /**
0192  * struct esw3 - Format 3 Extended Status Word (ESW)
0193  * @zero0: reserved zeros
0194  * @lpum: last path used mask
0195  * @res: reserved
0196  * @erw: extended report word
0197  * @zeros: three fullwords of zeros
0198  */
0199 struct esw3 {
0200     __u8  zero0;
0201     __u8  lpum;
0202     __u16 res;
0203     struct erw erw;
0204     __u32 zeros[3];
0205 } __attribute__ ((packed));
0206 
0207 /**
0208  * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
0209  * @sublog: subchannel logout
0210  * @erw: extended report word
0211  */
0212 struct esw_eadm {
0213     __u32 sublog;
0214     struct erw_eadm erw;
0215     __u32 : 32;
0216     __u32 : 32;
0217     __u32 : 32;
0218 } __packed;
0219 
0220 /**
0221  * struct irb - interruption response block
0222  * @scsw: subchannel status word
0223  * @esw: extended status word
0224  * @ecw: extended control word
0225  *
0226  * The irb that is handed to the device driver when an interrupt occurs. For
0227  * solicited interrupts, the common I/O layer already performs checks whether
0228  * a field is valid; a field not being valid is always passed as %0.
0229  * If a unit check occurred, @ecw may contain sense data; this is retrieved
0230  * by the common I/O layer itself if the device doesn't support concurrent
0231  * sense (so that the device driver never needs to perform basic sense itself).
0232  * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
0233  * if applicable).
0234  */
0235 struct irb {
0236     union scsw scsw;
0237     union {
0238         struct esw0 esw0;
0239         struct esw1 esw1;
0240         struct esw2 esw2;
0241         struct esw3 esw3;
0242         struct esw_eadm eadm;
0243     } esw;
0244     __u8   ecw[32];
0245 } __attribute__ ((packed,aligned(4)));
0246 
0247 /**
0248  * struct ciw - command information word  (CIW) layout
0249  * @et: entry type
0250  * @reserved: reserved bits
0251  * @ct: command type
0252  * @cmd: command code
0253  * @count: command count
0254  */
0255 struct ciw {
0256     __u32 et       :  2;
0257     __u32 reserved :  2;
0258     __u32 ct       :  4;
0259     __u32 cmd      :  8;
0260     __u32 count    : 16;
0261 } __attribute__ ((packed));
0262 
0263 #define CIW_TYPE_RCD    0x0     /* read configuration data */
0264 #define CIW_TYPE_SII    0x1     /* set interface identifier */
0265 #define CIW_TYPE_RNI    0x2     /* read node identifier */
0266 
0267 /*
0268  * Node Descriptor as defined in SA22-7204, "Common I/O-Device Commands"
0269  */
0270 
0271 #define ND_VALIDITY_VALID   0
0272 #define ND_VALIDITY_OUTDATED    1
0273 #define ND_VALIDITY_INVALID 2
0274 
0275 struct node_descriptor {
0276     /* Flags. */
0277     union {
0278         struct {
0279             u32 validity:3;
0280             u32 reserved:5;
0281         } __packed;
0282         u8 byte0;
0283     } __packed;
0284 
0285     /* Node parameters. */
0286     u32 params:24;
0287 
0288     /* Node ID. */
0289     char type[6];
0290     char model[3];
0291     char manufacturer[3];
0292     char plant[2];
0293     char seq[12];
0294     u16 tag;
0295 } __packed;
0296 
0297 /*
0298  * Flags used as input parameters for do_IO()
0299  */
0300 #define DOIO_ALLOW_SUSPEND   0x0001 /* allow for channel prog. suspend */
0301 #define DOIO_DENY_PREFETCH   0x0002 /* don't allow for CCW prefetch */
0302 #define DOIO_SUPPRESS_INTER  0x0004 /* suppress intermediate inter. */
0303                     /* ... for suspended CCWs */
0304 /* Device or subchannel gone. */
0305 #define CIO_GONE       0x0001
0306 /* No path to device. */
0307 #define CIO_NO_PATH    0x0002
0308 /* Device has appeared. */
0309 #define CIO_OPER       0x0004
0310 /* Sick revalidation of device. */
0311 #define CIO_REVALIDATE 0x0008
0312 /* Device did not respond in time. */
0313 #define CIO_BOXED      0x0010
0314 
0315 /**
0316  * struct ccw_dev_id - unique identifier for ccw devices
0317  * @ssid: subchannel set id
0318  * @devno: device number
0319  *
0320  * This structure is not directly based on any hardware structure. The
0321  * hardware identifies a device by its device number and its subchannel,
0322  * which is in turn identified by its id. In order to get a unique identifier
0323  * for ccw devices across subchannel sets, @struct ccw_dev_id has been
0324  * introduced.
0325  */
0326 struct ccw_dev_id {
0327     u8 ssid;
0328     u16 devno;
0329 };
0330 
0331 /**
0332  * ccw_dev_id_is_equal() - compare two ccw_dev_ids
0333  * @dev_id1: a ccw_dev_id
0334  * @dev_id2: another ccw_dev_id
0335  * Returns:
0336  *  %1 if the two structures are equal field-by-field,
0337  *  %0 if not.
0338  * Context:
0339  *  any
0340  */
0341 static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
0342                       struct ccw_dev_id *dev_id2)
0343 {
0344     if ((dev_id1->ssid == dev_id2->ssid) &&
0345         (dev_id1->devno == dev_id2->devno))
0346         return 1;
0347     return 0;
0348 }
0349 
0350 /**
0351  * pathmask_to_pos() - find the position of the left-most bit in a pathmask
0352  * @mask: pathmask with at least one bit set
0353  */
0354 static inline u8 pathmask_to_pos(u8 mask)
0355 {
0356     return 8 - ffs(mask);
0357 }
0358 
0359 extern void css_schedule_reprobe(void);
0360 
0361 extern void *cio_dma_zalloc(size_t size);
0362 extern void cio_dma_free(void *cpu_addr, size_t size);
0363 extern struct device *cio_get_dma_css_dev(void);
0364 
0365 void *cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
0366             size_t size);
0367 void cio_gp_dma_free(struct gen_pool *gp_dma, void *cpu_addr, size_t size);
0368 void cio_gp_dma_destroy(struct gen_pool *gp_dma, struct device *dma_dev);
0369 struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages);
0370 
0371 /* Function from drivers/s390/cio/chsc.c */
0372 int chsc_sstpc(void *page, unsigned int op, u16 ctrl, long *clock_delta);
0373 int chsc_sstpi(void *page, void *result, size_t size);
0374 int chsc_stzi(void *page, void *result, size_t size);
0375 int chsc_sgib(u32 origin);
0376 int chsc_scud(u16 cu, u64 *esm, u8 *esm_valid);
0377 
0378 #endif