css.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 <linux/device.h>
  7. #include <linux/types.h>
  8. #include <asm/cio.h>
  9. #include <asm/chpid.h>
  10. #include "schid.h"
  11. /*
  12. * path grouping stuff
  13. */
  14. #define SPID_FUNC_SINGLE_PATH 0x00
  15. #define SPID_FUNC_MULTI_PATH 0x80
  16. #define SPID_FUNC_ESTABLISH 0x00
  17. #define SPID_FUNC_RESIGN 0x40
  18. #define SPID_FUNC_DISBAND 0x20
  19. #define SNID_STATE1_RESET 0
  20. #define SNID_STATE1_UNGROUPED 2
  21. #define SNID_STATE1_GROUPED 3
  22. #define SNID_STATE2_NOT_RESVD 0
  23. #define SNID_STATE2_RESVD_ELSE 2
  24. #define SNID_STATE2_RESVD_SELF 3
  25. #define SNID_STATE3_MULTI_PATH 1
  26. #define SNID_STATE3_SINGLE_PATH 0
  27. struct path_state {
  28. __u8 state1 : 2; /* path state value 1 */
  29. __u8 state2 : 2; /* path state value 2 */
  30. __u8 state3 : 1; /* path state value 3 */
  31. __u8 resvd : 3; /* reserved */
  32. } __attribute__ ((packed));
  33. struct extended_cssid {
  34. u8 version;
  35. u8 cssid;
  36. } __attribute__ ((packed));
  37. struct pgid {
  38. union {
  39. __u8 fc; /* SPID function code */
  40. struct path_state ps; /* SNID path state */
  41. } __attribute__ ((packed)) inf;
  42. union {
  43. __u32 cpu_addr : 16; /* CPU address */
  44. struct extended_cssid ext_cssid;
  45. } __attribute__ ((packed)) pgid_high;
  46. __u32 cpu_id : 24; /* CPU identification */
  47. __u32 cpu_model : 16; /* CPU model */
  48. __u32 tod_high; /* high word TOD clock */
  49. } __attribute__ ((packed));
  50. #define MAX_CIWS 8
  51. /*
  52. * sense-id response buffer layout
  53. */
  54. struct senseid {
  55. /* common part */
  56. __u8 reserved; /* always 0x'FF' */
  57. __u16 cu_type; /* control unit type */
  58. __u8 cu_model; /* control unit model */
  59. __u16 dev_type; /* device type */
  60. __u8 dev_model; /* device model */
  61. __u8 unused; /* padding byte */
  62. /* extended part */
  63. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  64. } __attribute__ ((packed,aligned(4)));
  65. struct ccw_device_private {
  66. struct ccw_device *cdev;
  67. struct subchannel *sch;
  68. int state; /* device state */
  69. atomic_t onoff;
  70. unsigned long registered;
  71. struct ccw_dev_id dev_id; /* device id */
  72. struct subchannel_id schid; /* subchannel number */
  73. __u8 imask; /* lpm mask for SNID/SID/SPGID */
  74. int iretry; /* retry counter SNID/SID/SPGID */
  75. struct {
  76. unsigned int fast:1; /* post with "channel end" */
  77. unsigned int repall:1; /* report every interrupt status */
  78. unsigned int pgroup:1; /* do path grouping */
  79. unsigned int force:1; /* allow forced online */
  80. } __attribute__ ((packed)) options;
  81. struct {
  82. unsigned int pgid_single:1; /* use single path for Set PGID */
  83. unsigned int esid:1; /* Ext. SenseID supported by HW */
  84. unsigned int dosense:1; /* delayed SENSE required */
  85. unsigned int doverify:1; /* delayed path verification */
  86. unsigned int donotify:1; /* call notify function */
  87. unsigned int recog_done:1; /* dev. recog. complete */
  88. unsigned int fake_irb:1; /* deliver faked irb */
  89. unsigned int intretry:1; /* retry internal operation */
  90. } __attribute__((packed)) flags;
  91. unsigned long intparm; /* user interruption parameter */
  92. struct qdio_irq *qdio_data;
  93. struct irb irb; /* device status */
  94. struct senseid senseid; /* SenseID info */
  95. struct pgid pgid[8]; /* path group IDs per chpid*/
  96. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  97. struct work_struct kick_work;
  98. wait_queue_head_t wait_q;
  99. struct timer_list timer;
  100. void *cmb; /* measurement information */
  101. struct list_head cmb_list; /* list of measured devices */
  102. u64 cmb_start_time; /* clock value of cmb reset */
  103. void *cmb_wait; /* deferred cmb enable/disable */
  104. };
  105. /*
  106. * A css driver handles all subchannels of one type.
  107. * Currently, we only care about I/O subchannels (type 0), these
  108. * have a ccw_device connected to them.
  109. */
  110. struct subchannel;
  111. struct css_driver {
  112. unsigned int subchannel_type;
  113. struct device_driver drv;
  114. void (*irq)(struct device *);
  115. int (*notify)(struct device *, int);
  116. void (*verify)(struct device *);
  117. void (*termination)(struct device *);
  118. int (*probe)(struct subchannel *);
  119. int (*remove)(struct subchannel *);
  120. void (*shutdown)(struct subchannel *);
  121. };
  122. /*
  123. * all css_drivers have the css_bus_type
  124. */
  125. extern struct bus_type css_bus_type;
  126. extern int css_sch_device_register(struct subchannel *);
  127. extern void css_sch_device_unregister(struct subchannel *);
  128. extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
  129. extern int css_init_done;
  130. extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
  131. extern void css_process_crw(int, int);
  132. extern void css_reiterate_subchannels(void);
  133. void css_update_ssd_info(struct subchannel *sch);
  134. #define __MAX_SUBCHANNEL 65535
  135. #define __MAX_SSID 3
  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. void css_schedule_eval(struct subchannel_id schid);
  166. void css_schedule_eval_all(void);
  167. int sch_is_pseudo_sch(struct subchannel *);
  168. extern struct workqueue_struct *slow_path_wq;
  169. int subchannel_add_files (struct device *);
  170. extern struct attribute_group *subch_attr_groups[];
  171. #endif