blob: 20259f3fbf453c98bf11a69de568af534b69f210 [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
26
Cornelia Huck99611f82008-07-14 09:59:02 +020027struct chp_link {
Cornelia Huckc820de32008-07-14 09:58:45 +020028 struct chp_id chpid;
29 u32 fla_mask;
30 u16 fla;
31};
32
Peter Oberparleitere5854a52007-04-27 16:01:31 +020033static 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
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020042struct channel_path {
Sebastian Ottb730f3a2010-10-25 16:10:27 +020043 struct device dev;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020044 struct chp_id chpid;
Sebastian Ottb730f3a2010-10-25 16:10:27 +020045 struct mutex lock; /* Serialize access to below members. */
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020046 int state;
Sebastian Ottded27d82017-06-29 13:27:22 +020047 struct channel_path_desc_fmt0 desc;
Peter Oberparleitercce0eac2013-03-11 12:58:18 +010048 struct channel_path_desc_fmt1 desc_fmt1;
Sebastian Ottfcc6dd42016-06-22 19:42:40 +020049 struct channel_path_desc_fmt3 desc_fmt3;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020050 /* Channel-measurement related stuff: */
51 int cmg;
52 int shared;
Sebastian Ott0d9bfe92016-01-25 10:30:27 +010053 struct cmg_chars cmg_chars;
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020054};
55
Sebastian Ottc38a90a2010-10-25 16:10:31 +020056/* Return channel_path struct for given chpid. */
57static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
58{
Sebastian Ott98cc43a2016-11-08 14:28:03 +010059 return css_by_id(chpid.cssid)->chps[chpid.id];
Sebastian Ottc38a90a2010-10-25 16:10:31 +020060}
61
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020062int chp_get_status(struct chp_id chpid);
63u8 chp_get_sch_opm(struct subchannel *sch);
64int chp_is_registered(struct chp_id chpid);
Sebastian Ottded27d82017-06-29 13:27:22 +020065struct channel_path_desc_fmt0 *chp_get_chp_desc(struct chp_id chpid);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020066void chp_remove_cmg_attr(struct channel_path *chp);
67int chp_add_cmg_attr(struct channel_path *chp);
Peter Oberparleitercce0eac2013-03-11 12:58:18 +010068int chp_update_desc(struct channel_path *chp);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020069int chp_new(struct chp_id chpid);
Peter Oberparleitere5854a52007-04-27 16:01:31 +020070void chp_cfg_schedule(struct chp_id chpid, int configure);
71void chp_cfg_cancel_deconfigure(struct chp_id chpid);
72int chp_info_get_status(struct chp_id chpid);
Cornelia Huck99611f82008-07-14 09:59:02 +020073int chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020074#endif /* S390_CHP_H */