css.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #ifndef _CSS_H
  2. #define _CSS_H
  3. #include <linux/mutex.h>
  4. #include <linux/wait.h>
  5. #include <linux/workqueue.h>
  6. #include <asm/cio.h>
  7. #include "schid.h"
  8. /*
  9. * path grouping stuff
  10. */
  11. #define SPID_FUNC_SINGLE_PATH 0x00
  12. #define SPID_FUNC_MULTI_PATH 0x80
  13. #define SPID_FUNC_ESTABLISH 0x00
  14. #define SPID_FUNC_RESIGN 0x40
  15. #define SPID_FUNC_DISBAND 0x20
  16. #define SNID_STATE1_RESET 0
  17. #define SNID_STATE1_UNGROUPED 2
  18. #define SNID_STATE1_GROUPED 3
  19. #define SNID_STATE2_NOT_RESVD 0
  20. #define SNID_STATE2_RESVD_ELSE 2
  21. #define SNID_STATE2_RESVD_SELF 3
  22. #define SNID_STATE3_MULTI_PATH 1
  23. #define SNID_STATE3_SINGLE_PATH 0
  24. struct path_state {
  25. __u8 state1 : 2; /* path state value 1 */
  26. __u8 state2 : 2; /* path state value 2 */
  27. __u8 state3 : 1; /* path state value 3 */
  28. __u8 resvd : 3; /* reserved */
  29. } __attribute__ ((packed));
  30. struct extended_cssid {
  31. u8 version;
  32. u8 cssid;
  33. } __attribute__ ((packed));
  34. struct pgid {
  35. union {
  36. __u8 fc; /* SPID function code */
  37. struct path_state ps; /* SNID path state */
  38. } __attribute__ ((packed)) inf;
  39. union {
  40. __u32 cpu_addr : 16; /* CPU address */
  41. struct extended_cssid ext_cssid;
  42. } __attribute__ ((packed)) pgid_high;
  43. __u32 cpu_id : 24; /* CPU identification */
  44. __u32 cpu_model : 16; /* CPU model */
  45. __u32 tod_high; /* high word TOD clock */
  46. } __attribute__ ((packed));
  47. #define MAX_CIWS 8
  48. /*
  49. * sense-id response buffer layout
  50. */
  51. struct senseid {
  52. /* common part */
  53. __u8 reserved; /* always 0x'FF' */
  54. __u16 cu_type; /* control unit type */
  55. __u8 cu_model; /* control unit model */
  56. __u16 dev_type; /* device type */
  57. __u8 dev_model; /* device model */
  58. __u8 unused; /* padding byte */
  59. /* extended part */
  60. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  61. } __attribute__ ((packed,aligned(4)));
  62. struct ccw_device_private {
  63. int state; /* device state */
  64. atomic_t onoff;
  65. unsigned long registered;
  66. struct ccw_dev_id dev_id; /* device id */
  67. struct subchannel_id schid; /* subchannel number */
  68. __u8 imask; /* lpm mask for SNID/SID/SPGID */
  69. int iretry; /* retry counter SNID/SID/SPGID */
  70. struct {
  71. unsigned int fast:1; /* post with "channel end" */
  72. unsigned int repall:1; /* report every interrupt status */
  73. unsigned int pgroup:1; /* do path grouping */
  74. unsigned int force:1; /* allow forced online */
  75. } __attribute__ ((packed)) options;
  76. struct {
  77. unsigned int pgid_single:1; /* use single path for Set PGID */
  78. unsigned int esid:1; /* Ext. SenseID supported by HW */
  79. unsigned int dosense:1; /* delayed SENSE required */
  80. unsigned int doverify:1; /* delayed path verification */
  81. unsigned int donotify:1; /* call notify function */
  82. unsigned int recog_done:1; /* dev. recog. complete */
  83. unsigned int fake_irb:1; /* deliver faked irb */
  84. } __attribute__((packed)) flags;
  85. unsigned long intparm; /* user interruption parameter */
  86. struct qdio_irq *qdio_data;
  87. struct irb irb; /* device status */
  88. struct senseid senseid; /* SenseID info */
  89. struct pgid pgid[8]; /* path group IDs per chpid*/
  90. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  91. struct work_struct kick_work;
  92. wait_queue_head_t wait_q;
  93. struct timer_list timer;
  94. void *cmb; /* measurement information */
  95. struct list_head cmb_list; /* list of measured devices */
  96. u64 cmb_start_time; /* clock value of cmb reset */
  97. void *cmb_wait; /* deferred cmb enable/disable */
  98. };
  99. /*
  100. * A css driver handles all subchannels of one type.
  101. * Currently, we only care about I/O subchannels (type 0), these
  102. * have a ccw_device connected to them.
  103. */
  104. struct subchannel;
  105. struct css_driver {
  106. unsigned int subchannel_type;
  107. struct device_driver drv;
  108. void (*irq)(struct device *);
  109. int (*notify)(struct device *, int);
  110. void (*verify)(struct device *);
  111. void (*termination)(struct device *);
  112. int (*probe)(struct subchannel *);
  113. int (*remove)(struct subchannel *);
  114. void (*shutdown)(struct subchannel *);
  115. };
  116. /*
  117. * all css_drivers have the css_bus_type
  118. */
  119. extern struct bus_type css_bus_type;
  120. extern struct css_driver io_subchannel_driver;
  121. extern int css_probe_device(struct subchannel_id);
  122. extern int css_sch_device_register(struct subchannel *);
  123. extern void css_sch_device_unregister(struct subchannel *);
  124. extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
  125. extern int css_init_done;
  126. extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
  127. #define __MAX_SUBCHANNEL 65535
  128. #define __MAX_SSID 3
  129. #define __MAX_CHPID 255
  130. #define __MAX_CSSID 0
  131. struct channel_subsystem {
  132. u8 cssid;
  133. int valid;
  134. struct channel_path *chps[__MAX_CHPID + 1];
  135. struct device device;
  136. struct pgid global_pgid;
  137. struct mutex mutex;
  138. /* channel measurement related */
  139. int cm_enabled;
  140. void *cub_addr1;
  141. void *cub_addr2;
  142. };
  143. #define to_css(dev) container_of(dev, struct channel_subsystem, device)
  144. extern struct bus_type css_bus_type;
  145. extern struct channel_subsystem *css[];
  146. /* Some helper functions for disconnected state. */
  147. int device_is_disconnected(struct subchannel *);
  148. void device_set_disconnected(struct subchannel *);
  149. void device_trigger_reprobe(struct subchannel *);
  150. /* Helper functions for vary on/off. */
  151. int device_is_online(struct subchannel *);
  152. void device_kill_io(struct subchannel *);
  153. /* Machine check helper function. */
  154. void device_kill_pending_timer(struct subchannel *);
  155. /* Helper functions to build lists for the slow path. */
  156. extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
  157. void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
  158. void css_clear_subchannel_slow_list(void);
  159. int css_slow_subchannels_exist(void);
  160. extern int need_rescan;
  161. extern struct workqueue_struct *slow_path_wq;
  162. extern struct work_struct slow_path_work;
  163. #endif