summaryrefslogtreecommitdiffstats
path: root/include/asm-s390/ccwcache.h
blob: cfbb03bf29746e496e5c1d13ca3105b0eeccefc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* 
   * File...........: linux/include/asm-s390/ccwcache.h
   * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
   * Bugreports.to..: <Linux390@de.ibm.com>
   * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
 */
#ifndef CCWCACHE_H
#define CCWCACHE_H
#include <linux/slab.h>
#include <asm/irq.h>

#ifndef __KERNEL__
#define kmem_cache_t void
#endif /* __KERNEL__ */

typedef struct ccw_req_t {
	/* eye catcher plus queueing information  */
	unsigned int magic;	
	struct ccw_req_t *next;	/* pointer to next ccw_req_t in queue */
	struct ccw_req_t *int_next;	/* for internal queueing */
	struct ccw_req_t *int_prev;	/* for internal queueing */

	/* Where to execute what... */
	void *device;		/* index of the device the req is for */
	void *req;		/* pointer to originating request */
	ccw1_t *cpaddr;		/* address of channel program */
	char status;	        /* reflecting the status of this request */
	char flags;              /* see below */
	short retries;		/* A retry counter to be set when filling */

	/* ... and how */
	int options;		/* options for execution */
	char lpm;               /* logical path mask                      */
	void *data;		/* pointer to data area */
	devstat_t *dstat;	/* The device status in case of an error */

	/* these are important for recovering erroneous requests          */
	struct ccw_req_t *refers;	/* Does this request refer to another one? */
	void *function; /* refers to the originating ERP action */ ;

	unsigned long long expires;	/* expiratioj period */
	/* these are for profiling purposes */
	unsigned long long buildclk;	/* TOD-clock of request generation */
	unsigned long long startclk;	/* TOD-clock of request start */
	unsigned long long stopclk;	/* TOD-clock of request interrupt */
	unsigned long long endclk;	/* TOD-clock of request termination */

	/* these are for internal use */
	int cplength;		/* length of the channel program in CCWs */
	int datasize;		/* amount of additional data in bytes */
	kmem_cache_t *cache;	/* the cache this data comes from */

} __attribute__ ((aligned(4))) ccw_req_t;

/* 
 * ccw_req_t -> status can be:
 */
#define CQR_STATUS_EMPTY    0x00	/* request is empty */
#define CQR_STATUS_FILLED   0x01	/* request is ready to be preocessed */
#define CQR_STATUS_QUEUED   0x02	/* request is queued to be processed */
#define CQR_STATUS_IN_IO    0x03	/* request is currently in IO */
#define CQR_STATUS_DONE     0x04	/* request is completed sucessfully */
#define CQR_STATUS_ERROR    0x05	/* request is completed with error */
#define CQR_STATUS_FAILED   0x06	/* request is finally failed */

#define CQR_FLAGS_CHAINED  0x01	/* request is chained by another (last CCW is TIC) */

#ifdef __KERNEL__
#define SMALLEST_SLAB (sizeof(struct ccw_req_t) <= 128 ? 128 :\
 sizeof(struct ccw_req_t) <= 256 ? 256 : 512 )

/* SMALLEST_SLAB(1),... PAGE_SIZE(CCW_NUMBER_CACHES) */
#define CCW_NUMBER_CACHES (sizeof(struct ccw_req_t) <= 128 ? 6 :\
 sizeof(struct ccw_req_t) <= 256 ? 5 : 4 )

int ccwcache_init (void);

ccw_req_t *ccw_alloc_request (char *magic, int cplength, int additional_data);
void ccw_free_request (ccw_req_t * request);
#endif /* __KERNEL__ */
#endif				/* CCWCACHE_H */