css.h 4.6 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. /*
  30. * Conditions used to specify which subchannels need evaluation
  31. */
  32. enum css_eval_cond {
  33. CSS_EVAL_UNREG, /* unregistered subchannels */
  34. CSS_EVAL_NOT_ONLINE /* sch without an online-device */
  35. };
  36. struct path_state {
  37. __u8 state1 : 2; /* path state value 1 */
  38. __u8 state2 : 2; /* path state value 2 */
  39. __u8 state3 : 1; /* path state value 3 */
  40. __u8 resvd : 3; /* reserved */
  41. } __attribute__ ((packed));
  42. struct extended_cssid {
  43. u8 version;
  44. u8 cssid;
  45. } __attribute__ ((packed));
  46. struct pgid {
  47. union {
  48. __u8 fc; /* SPID function code */
  49. struct path_state ps; /* SNID path state */
  50. } __attribute__ ((packed)) inf;
  51. union {
  52. __u32 cpu_addr : 16; /* CPU address */
  53. struct extended_cssid ext_cssid;
  54. } __attribute__ ((packed)) pgid_high;
  55. __u32 cpu_id : 24; /* CPU identification */
  56. __u32 cpu_model : 16; /* CPU model */
  57. __u32 tod_high; /* high word TOD clock */
  58. } __attribute__ ((packed));
  59. struct subchannel;
  60. struct chp_link;
  61. /**
  62. * struct css_driver - device driver for subchannels
  63. * @subchannel_type: subchannel type supported by this driver
  64. * @drv: embedded device driver structure
  65. * @irq: called on interrupts
  66. * @chp_event: called for events affecting a channel path
  67. * @sch_event: called for events affecting the subchannel
  68. * @probe: function called on probe
  69. * @remove: function called on remove
  70. * @shutdown: called at device shutdown
  71. * @settle: wait for asynchronous work to finish
  72. */
  73. struct css_driver {
  74. struct css_device_id *subchannel_type;
  75. struct device_driver drv;
  76. void (*irq)(struct subchannel *);
  77. int (*chp_event)(struct subchannel *, struct chp_link *, int);
  78. int (*sch_event)(struct subchannel *, int);
  79. int (*probe)(struct subchannel *);
  80. void (*remove)(struct subchannel *);
  81. void (*shutdown)(struct subchannel *);
  82. int (*settle)(void);
  83. };
  84. #define to_cssdriver(n) container_of(n, struct css_driver, drv)
  85. extern int css_driver_register(struct css_driver *);
  86. extern void css_driver_unregister(struct css_driver *);
  87. extern void css_sch_device_unregister(struct subchannel *);
  88. extern int css_register_subchannel(struct subchannel *);
  89. extern struct subchannel *css_alloc_subchannel(struct subchannel_id,
  90. struct schib *schib);
  91. extern struct subchannel *get_subchannel_by_schid(struct subchannel_id);
  92. extern int css_init_done;
  93. extern int max_ssid;
  94. int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
  95. int (*fn_unknown)(struct subchannel_id,
  96. void *), void *data);
  97. extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
  98. void css_update_ssd_info(struct subchannel *sch);
  99. struct channel_subsystem {
  100. u8 cssid;
  101. u8 iid;
  102. bool id_valid; /* cssid,iid */
  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. /* Dummy helper which needs to change once we support more than one css. */
  117. static inline struct channel_subsystem *css_by_id(u8 cssid)
  118. {
  119. return channel_subsystems[0];
  120. }
  121. /* Dummy iterator which needs to change once we support more than one css. */
  122. #define for_each_css(css) \
  123. for ((css) = channel_subsystems[0]; (css); (css) = NULL)
  124. /* Helper functions to build lists for the slow path. */
  125. void css_schedule_eval(struct subchannel_id schid);
  126. void css_schedule_eval_all(void);
  127. void css_schedule_eval_cond(enum css_eval_cond, unsigned long delay);
  128. int css_complete_work(void);
  129. int sch_is_pseudo_sch(struct subchannel *);
  130. struct schib;
  131. int css_sch_is_valid(struct schib *);
  132. extern struct workqueue_struct *cio_work_q;
  133. void css_wait_for_slow_path(void);
  134. void css_sched_sch_todo(struct subchannel *sch, enum sch_todo todo);
  135. #endif