GNU Linux-libre 4.14.259-gnu1
[releases.git] / drivers / s390 / cio / chp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *    Copyright IBM Corp. 2007, 2010
4  *    Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
5  */
6
7 #ifndef S390_CHP_H
8 #define S390_CHP_H
9
10 #include <linux/types.h>
11 #include <linux/device.h>
12 #include <linux/mutex.h>
13 #include <asm/chpid.h>
14 #include "chsc.h"
15 #include "css.h"
16
17 #define CHP_STATUS_STANDBY              0
18 #define CHP_STATUS_CONFIGURED           1
19 #define CHP_STATUS_RESERVED             2
20 #define CHP_STATUS_NOT_RECOGNIZED       3
21
22 #define CHP_ONLINE 0
23 #define CHP_OFFLINE 1
24 #define CHP_VARY_ON 2
25 #define CHP_VARY_OFF 3
26
27 struct chp_link {
28         struct chp_id chpid;
29         u32 fla_mask;
30         u16 fla;
31 };
32
33 static inline int chp_test_bit(u8 *bitmap, int num)
34 {
35         int byte = num >> 3;
36         int mask = 128 >> (num & 7);
37
38         return (bitmap[byte] & mask) ? 1 : 0;
39 }
40
41
42 struct channel_path {
43         struct device dev;
44         struct chp_id chpid;
45         struct mutex lock; /* Serialize access to below members. */
46         int state;
47         struct channel_path_desc desc;
48         struct channel_path_desc_fmt1 desc_fmt1;
49         /* Channel-measurement related stuff: */
50         int cmg;
51         int shared;
52         struct cmg_chars cmg_chars;
53 };
54
55 /* Return channel_path struct for given chpid. */
56 static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
57 {
58         return css_by_id(chpid.cssid)->chps[chpid.id];
59 }
60
61 int chp_get_status(struct chp_id chpid);
62 u8 chp_get_sch_opm(struct subchannel *sch);
63 int chp_is_registered(struct chp_id chpid);
64 struct channel_path_desc *chp_get_chp_desc(struct chp_id chpid);
65 void chp_remove_cmg_attr(struct channel_path *chp);
66 int chp_add_cmg_attr(struct channel_path *chp);
67 int chp_update_desc(struct channel_path *chp);
68 int chp_new(struct chp_id chpid);
69 void chp_cfg_schedule(struct chp_id chpid, int configure);
70 void chp_cfg_cancel_deconfigure(struct chp_id chpid);
71 int chp_info_get_status(struct chp_id chpid);
72 int chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *);
73 #endif /* S390_CHP_H */