css.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. struct ccw_device *cdev;
  64. struct subchannel *sch;
  65. int state; /* device state */
  66. atomic_t onoff;
  67. unsigned long registered;
  68. struct ccw_dev_id dev_id; /* device id */
  69. struct subchannel_id schid; /* subchannel number */
  70. __u8 imask; /* lpm mask for SNID/SID/SPGID */
  71. int iretry; /* retry counter SNID/SID/SPGID */
  72. struct {
  73. unsigned int fast:1; /* post with "channel end" */
  74. unsigned int repall:1; /* report every interrupt status */
  75. unsigned int pgroup:1; /* do path grouping */
  76. unsigned int force:1; /* allow forced online */
  77. } __attribute__ ((packed)) options;
  78. struct {
  79. unsigned int pgid_single:1; /* use single path for Set PGID */
  80. unsigned int esid:1; /* Ext. SenseID supported by HW */
  81. unsigned int dosense:1; /* delayed SENSE required */
  82. unsigned int doverify:1; /* delayed path verification */
  83. unsigned int donotify:1; /* call notify function */
  84. unsigned int recog_done:1; /* dev. recog. complete */
  85. unsigned int fake_irb:1; /* deliver faked irb */
  86. unsigned int intretry:1; /* retry internal operation */
  87. } __attribute__((packed)) flags;
  88. unsigned long intparm; /* user interruption parameter */
  89. struct qdio_irq *qdio_data;
  90. struct irb irb; /* device status */
  91. struct senseid senseid; /* SenseID info */
  92. struct pgid pgid[8]; /* path group IDs per chpid*/
  93. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  94. struct work_struct kick_work;
  95. wait_queue_head_t wait_q;
  96. struct timer_list timer;
  97. void *cmb; /* measurement information */
  98. struct list_head cmb_list; /* list of measured devices */
  99. u64 cmb_start_time; /* clock value of cmb reset */
  100. void *cmb_wait; /* deferred cmb enable/disable */
  101. };
  102. /*
  103. * A css driver handles all subchannels of one type.
  104. * Currently, we only care about I/O subchannels (type 0), these
  105. * have a ccw_device connected to them.
  106. */
  107. struct subchannel;
  108. struct css_driver {
  109. unsigned int subchannel_type;
  110. struct device_driver drv;
  111. void (*irq)(struct device *);
  112. int (*notify)(struct device *, int);
  113. void (*verify)(struct device *);
  114. void (*termination)(struct device *);
  115. int (*probe)(struct subchannel *);
  116. int (*remove)(struct subchannel *);
  117. void (*shutdown)(struct subchannel *);
  118. };
  119. /*
  120. * all css_drivers have the css_bus_type
  121. */
  122. extern struct bus_type css_bus_type;
  123. extern struct css_driver io_subchannel_driver;
  124. extern int css_probe_device(struct subchannel_id);
  125. extern int css_sch_device_register(struct subchannel *);
  126. extern void css_sch_device_unregister(struct subchannel *);
  127. extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
  128. extern int css_init_done;
  129. extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
  130. extern int css_process_crw(int, int);
  131. extern void css_reiterate_subchannels(void);
  132. #define __MAX_SUBCHANNEL 65535
  133. #define __MAX_SSID 3
  134. #define __MAX_CHPID 255
  135. #define __MAX_CSSID 0
  136. struct channel_subsystem {
  137. u8 cssid;
  138. int valid;
  139. struct channel_path *chps[__MAX_CHPID + 1];
  140. struct device device;
  141. struct pgid global_pgid;
  142. struct mutex mutex;
  143. /* channel measurement related */
  144. int cm_enabled;
  145. void *cub_addr1;
  146. void *cub_addr2;
  147. /* for orphaned ccw devices */
  148. struct subchannel *pseudo_subchannel;
  149. };
  150. #define to_css(dev) container_of(dev, struct channel_subsystem, device)
  151. extern struct bus_type css_bus_type;
  152. extern struct channel_subsystem *css[];
  153. /* Some helper functions for disconnected state. */
  154. int device_is_disconnected(struct subchannel *);
  155. void device_set_disconnected(struct subchannel *);
  156. void device_trigger_reprobe(struct subchannel *);
  157. /* Helper functions for vary on/off. */
  158. int device_is_online(struct subchannel *);
  159. void device_kill_io(struct subchannel *);
  160. void device_set_intretry(struct subchannel *sch);
  161. int device_trigger_verify(struct subchannel *sch);
  162. /* Machine check helper function. */
  163. void device_kill_pending_timer(struct subchannel *);
  164. /* Helper functions to build lists for the slow path. */
  165. extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
  166. void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
  167. void css_clear_subchannel_slow_list(void);
  168. int css_slow_subchannels_exist(void);
  169. extern int need_rescan;
  170. int sch_is_pseudo_sch(struct subchannel *);
  171. extern struct workqueue_struct *slow_path_wq;
  172. extern struct work_struct slow_path_work;
  173. int subchannel_add_files (struct device *);
  174. extern struct attribute_group *subch_attr_groups[];
  175. #endif