css.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 <asm/schid.h>
  11. #include "cio.h"
  12. /*
  13. * path grouping stuff
  14. */
  15. #define SPID_FUNC_SINGLE_PATH 0x00
  16. #define SPID_FUNC_MULTI_PATH 0x80
  17. #define SPID_FUNC_ESTABLISH 0x00
  18. #define SPID_FUNC_RESIGN 0x40
  19. #define SPID_FUNC_DISBAND 0x20
  20. #define SNID_STATE1_RESET 0
  21. #define SNID_STATE1_UNGROUPED 2
  22. #define SNID_STATE1_GROUPED 3
  23. #define SNID_STATE2_NOT_RESVD 0
  24. #define SNID_STATE2_RESVD_ELSE 2
  25. #define SNID_STATE2_RESVD_SELF 3
  26. #define SNID_STATE3_MULTI_PATH 1
  27. #define SNID_STATE3_SINGLE_PATH 0
  28. struct path_state {
  29. __u8 state1 : 2; /* path state value 1 */
  30. __u8 state2 : 2; /* path state value 2 */
  31. __u8 state3 : 1; /* path state value 3 */
  32. __u8 resvd : 3; /* reserved */
  33. } __attribute__ ((packed));
  34. struct extended_cssid {
  35. u8 version;
  36. u8 cssid;
  37. } __attribute__ ((packed));
  38. struct pgid {
  39. union {
  40. __u8 fc; /* SPID function code */
  41. struct path_state ps; /* SNID path state */
  42. } __attribute__ ((packed)) inf;
  43. union {
  44. __u32 cpu_addr : 16; /* CPU address */
  45. struct extended_cssid ext_cssid;
  46. } __attribute__ ((packed)) pgid_high;
  47. __u32 cpu_id : 24; /* CPU identification */
  48. __u32 cpu_model : 16; /* CPU model */
  49. __u32 tod_high; /* high word TOD clock */
  50. } __attribute__ ((packed));
  51. struct subchannel;
  52. struct chp_link;
  53. /**
  54. * struct css_driver - device driver for subchannels
  55. * @subchannel_type: subchannel type supported by this driver
  56. * @drv: embedded device driver structure
  57. * @irq: called on interrupts
  58. * @chp_event: called for events affecting a channel path
  59. * @sch_event: called for events affecting the subchannel
  60. * @probe: function called on probe
  61. * @remove: function called on remove
  62. * @shutdown: called at device shutdown
  63. * @prepare: prepare for pm state transition
  64. * @complete: undo work done in @prepare
  65. * @freeze: callback for freezing during hibernation snapshotting
  66. * @thaw: undo work done in @freeze
  67. * @restore: callback for restoring after hibernation
  68. * @settle: wait for asynchronous work to finish
  69. */
  70. struct css_driver {
  71. struct css_device_id *subchannel_type;
  72. struct device_driver drv;
  73. void (*irq)(struct subchannel *);
  74. int (*chp_event)(struct subchannel *, struct chp_link *, int);
  75. int (*sch_event)(struct subchannel *, int);
  76. int (*probe)(struct subchannel *);
  77. int (*remove)(struct subchannel *);
  78. void (*shutdown)(struct subchannel *);
  79. int (*prepare) (struct subchannel *);
  80. void (*complete) (struct subchannel *);
  81. int (*freeze)(struct subchannel *);
  82. int (*thaw) (struct subchannel *);
  83. int (*restore)(struct subchannel *);
  84. int (*settle)(void);
  85. };
  86. #define to_cssdriver(n) container_of(n, struct css_driver, drv)
  87. extern int css_driver_register(struct css_driver *);
  88. extern void css_driver_unregister(struct css_driver *);
  89. extern void css_sch_device_unregister(struct subchannel *);
  90. extern int css_register_subchannel(struct subchannel *);
  91. extern struct subchannel *css_alloc_subchannel(struct subchannel_id);
  92. extern struct subchannel *get_subchannel_by_schid(struct subchannel_id);
  93. extern int css_init_done;
  94. extern int max_ssid;
  95. int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
  96. int (*fn_unknown)(struct subchannel_id,
  97. void *), void *data);
  98. extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
  99. void css_update_ssd_info(struct subchannel *sch);
  100. struct channel_subsystem {
  101. u8 cssid;
  102. int valid;
  103. struct channel_path *chps[__MAX_CHPID + 1];
  104. struct device device;
  105. struct pgid global_pgid;
  106. struct mutex mutex;
  107. /* channel measurement related */
  108. int cm_enabled;
  109. void *cub_addr1;
  110. void *cub_addr2;
  111. /* for orphaned ccw devices */
  112. struct subchannel *pseudo_subchannel;
  113. };
  114. #define to_css(dev) container_of(dev, struct channel_subsystem, device)
  115. extern struct channel_subsystem *channel_subsystems[];
  116. /* Helper functions to build lists for the slow path. */
  117. void css_schedule_eval(struct subchannel_id schid);
  118. void css_schedule_eval_all(void);
  119. void css_schedule_eval_all_unreg(unsigned long delay);
  120. int css_complete_work(void);
  121. int sch_is_pseudo_sch(struct subchannel *);
  122. struct schib;
  123. int css_sch_is_valid(struct schib *);
  124. extern struct workqueue_struct *cio_work_q;
  125. void css_wait_for_slow_path(void);
  126. void css_sched_sch_todo(struct subchannel *sch, enum sch_todo todo);
  127. #endif