blob: 7ee9eba0abcbfaca6915263c06c89e096f54ebdb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Peter Oberparleitere6b6e102007-04-27 16:01:28 +02002/*
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02003 * Copyright IBM Corp. 2007, 2010
Peter Oberparleitere6b6e102007-04-27 16:01:28 +02004 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
5 */
6
7#ifndef S390_CHP_H
Daniel van Gerpen99ec1112016-05-23 15:19:38 +02008#define S390_CHP_H
Peter Oberparleitere6b6e102007-04-27 16:01:28 +02009
10#include <linux/types.h>
11#include <linux/device.h>
Sebastian Ottb730f3a2010-10-25 16:10:27 +020012#include <linux/mutex.h>
Peter Oberparleitere5854a52007-04-27 16:01:31 +020013#include <asm/chpid.h>
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020014#include "chsc.h"
Cornelia Huck0ae7a7b2008-07-14 09:58:43 +020015#include "css.h"
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020016
Peter Oberparleitere5854a52007-04-27 16:01:31 +020017#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
Cornelia Huckc820de32008-07-14 09:58:45 +020022#define CHP_ONLINE 0
23#define CHP_OFFLINE 1
24#define CHP_VARY_ON 2
25#define CHP_VARY_OFF 3
Vineeth Vijayan32ef9382020-10-08 15:13:29 +020026#define CHP_FCES_EVENT 4
Cornelia Huckc820de32008-07-14 09:58:45 +020027
Cornelia Huck99611f82008-07-14 09:59:02 +020028struct chp_link {
Cornelia Huckc820de32008-07-14 09:58:45 +020029 struct chp_id chpid;
30 u32 fla_mask;
31 u16 fla;
32};
33
Peter Oberparleitere5854a52007-04-27 16:01:31 +020034static inline int chp_test_bit(u8 *bitmap, int num)
35{
36 int byte = num >> 3;
37 int mask = 128 >> (num & 7);
38
39 return (bitmap[byte] & mask) ? 1 : 0;
40}
41
42
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020043struct channel_path {
Sebastian Ottb730f3a2010-10-25 16:10:27 +020044 struct device dev;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020045 struct chp_id chpid;
Sebastian Ottb730f3a2010-10-25 16:10:27 +020046 struct mutex lock; /* Serialize access to below members. */
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020047 int state;
Sebastian Ottded27d82017-06-29 13:27:22 +020048 struct channel_path_desc_fmt0 desc;
Peter Oberparleitercce0eac2013-03-11 12:58:18 +010049 struct channel_path_desc_fmt1 desc_fmt1;
Sebastian Ottfcc6dd42016-06-22 19:42:40 +020050 struct channel_path_desc_fmt3 desc_fmt3;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020051 /* Channel-measurement related stuff: */
52 int cmg;
53 int shared;
Sebastian Ott0d9bfe92016-01-25 10:30:27 +010054 struct cmg_chars cmg_chars;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020055};
56
Sebastian Ottc38a90a2010-10-25 16:10:31 +020057/* Return channel_path struct for given chpid. */
58static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
59{
Sebastian Ott98cc43a2016-11-08 14:28:03 +010060 return css_by_id(chpid.cssid)->chps[chpid.id];
Sebastian Ottc38a90a2010-10-25 16:10:31 +020061}
62
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020063int chp_get_status(struct chp_id chpid);
64u8 chp_get_sch_opm(struct subchannel *sch);
65int chp_is_registered(struct chp_id chpid);
Sebastian Ottded27d82017-06-29 13:27:22 +020066struct channel_path_desc_fmt0 *chp_get_chp_desc(struct chp_id chpid);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020067void chp_remove_cmg_attr(struct channel_path *chp);
68int chp_add_cmg_attr(struct channel_path *chp);
Peter Oberparleitercce0eac2013-03-11 12:58:18 +010069int chp_update_desc(struct channel_path *chp);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020070int chp_new(struct chp_id chpid);
Peter Oberparleitere5854a52007-04-27 16:01:31 +020071void chp_cfg_schedule(struct chp_id chpid, int configure);
72void chp_cfg_cancel_deconfigure(struct chp_id chpid);
73int chp_info_get_status(struct chp_id chpid);
Cornelia Huck99611f82008-07-14 09:59:02 +020074int chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020075#endif /* S390_CHP_H */