css.h 4.8 KB

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