Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _CSS_H
0003 #define _CSS_H
0004 
0005 #include <linux/mutex.h>
0006 #include <linux/wait.h>
0007 #include <linux/workqueue.h>
0008 #include <linux/device.h>
0009 #include <linux/types.h>
0010 
0011 #include <asm/cio.h>
0012 #include <asm/chpid.h>
0013 #include <asm/schid.h>
0014 
0015 #include "cio.h"
0016 
0017 /*
0018  * path grouping stuff
0019  */
0020 #define SPID_FUNC_SINGLE_PATH      0x00
0021 #define SPID_FUNC_MULTI_PATH       0x80
0022 #define SPID_FUNC_ESTABLISH    0x00
0023 #define SPID_FUNC_RESIGN       0x40
0024 #define SPID_FUNC_DISBAND      0x20
0025 
0026 #define SNID_STATE1_RESET      0
0027 #define SNID_STATE1_UNGROUPED      2
0028 #define SNID_STATE1_GROUPED    3
0029 
0030 #define SNID_STATE2_NOT_RESVD      0
0031 #define SNID_STATE2_RESVD_ELSE     2
0032 #define SNID_STATE2_RESVD_SELF     3
0033 
0034 #define SNID_STATE3_MULTI_PATH     1
0035 #define SNID_STATE3_SINGLE_PATH    0
0036 
0037 /*
0038  * Conditions used to specify which subchannels need evaluation
0039  */
0040 enum css_eval_cond {
0041     CSS_EVAL_UNREG,     /* unregistered subchannels */
0042     CSS_EVAL_NOT_ONLINE /* sch without an online-device */
0043 };
0044 
0045 struct path_state {
0046     __u8  state1 : 2;   /* path state value 1 */
0047     __u8  state2 : 2;   /* path state value 2 */
0048     __u8  state3 : 1;   /* path state value 3 */
0049     __u8  resvd  : 3;   /* reserved */
0050 } __attribute__ ((packed));
0051 
0052 struct extended_cssid {
0053     u8 version;
0054     u8 cssid;
0055 } __attribute__ ((packed));
0056 
0057 struct pgid {
0058     union {
0059         __u8 fc;    /* SPID function code */
0060         struct path_state ps;   /* SNID path state */
0061     } __attribute__ ((packed)) inf;
0062     union {
0063         __u32 cpu_addr  : 16;   /* CPU address */
0064         struct extended_cssid ext_cssid;
0065     } __attribute__ ((packed)) pgid_high;
0066     __u32 cpu_id    : 24;   /* CPU identification */
0067     __u32 cpu_model : 16;   /* CPU model */
0068     __u32 tod_high;     /* high word TOD clock */
0069 } __attribute__ ((packed));
0070 
0071 struct subchannel;
0072 struct chp_link;
0073 /**
0074  * struct css_driver - device driver for subchannels
0075  * @subchannel_type: subchannel type supported by this driver
0076  * @drv: embedded device driver structure
0077  * @irq: called on interrupts
0078  * @chp_event: called for events affecting a channel path
0079  * @sch_event: called for events affecting the subchannel
0080  * @probe: function called on probe
0081  * @remove: function called on remove
0082  * @shutdown: called at device shutdown
0083  * @settle: wait for asynchronous work to finish
0084  */
0085 struct css_driver {
0086     struct css_device_id *subchannel_type;
0087     struct device_driver drv;
0088     void (*irq)(struct subchannel *);
0089     int (*chp_event)(struct subchannel *, struct chp_link *, int);
0090     int (*sch_event)(struct subchannel *, int);
0091     int (*probe)(struct subchannel *);
0092     void (*remove)(struct subchannel *);
0093     void (*shutdown)(struct subchannel *);
0094     int (*settle)(void);
0095 };
0096 
0097 #define to_cssdriver(n) container_of(n, struct css_driver, drv)
0098 
0099 extern int css_driver_register(struct css_driver *);
0100 extern void css_driver_unregister(struct css_driver *);
0101 
0102 extern void css_sch_device_unregister(struct subchannel *);
0103 extern int css_register_subchannel(struct subchannel *);
0104 extern struct subchannel *css_alloc_subchannel(struct subchannel_id,
0105                            struct schib *schib);
0106 extern struct subchannel *get_subchannel_by_schid(struct subchannel_id);
0107 extern int css_init_done;
0108 extern int max_ssid;
0109 int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
0110                    int (*fn_unknown)(struct subchannel_id,
0111                    void *), void *data);
0112 extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
0113 void css_update_ssd_info(struct subchannel *sch);
0114 
0115 struct channel_subsystem {
0116     u8 cssid;
0117     u8 iid;
0118     bool id_valid; /* cssid,iid */
0119     struct channel_path *chps[__MAX_CHPID + 1];
0120     struct device device;
0121     struct pgid global_pgid;
0122     struct mutex mutex;
0123     /* channel measurement related */
0124     int cm_enabled;
0125     void *cub_addr1;
0126     void *cub_addr2;
0127     /* for orphaned ccw devices */
0128     struct subchannel *pseudo_subchannel;
0129 };
0130 #define to_css(dev) container_of(dev, struct channel_subsystem, device)
0131 
0132 extern struct channel_subsystem *channel_subsystems[];
0133 
0134 /* Dummy helper which needs to change once we support more than one css. */
0135 static inline struct channel_subsystem *css_by_id(u8 cssid)
0136 {
0137     return channel_subsystems[0];
0138 }
0139 
0140 /* Dummy iterator which needs to change once we support more than one css. */
0141 #define for_each_css(css)                       \
0142     for ((css) = channel_subsystems[0]; (css); (css) = NULL)
0143 
0144 /* Helper functions to build lists for the slow path. */
0145 void css_schedule_eval(struct subchannel_id schid);
0146 void css_schedule_eval_all(void);
0147 void css_schedule_eval_cond(enum css_eval_cond, unsigned long delay);
0148 int css_complete_work(void);
0149 
0150 int sch_is_pseudo_sch(struct subchannel *);
0151 struct schib;
0152 int css_sch_is_valid(struct schib *);
0153 
0154 extern struct workqueue_struct *cio_work_q;
0155 void css_wait_for_slow_path(void);
0156 void css_sched_sch_todo(struct subchannel *sch, enum sch_todo todo);
0157 #endif