xref: /kernel/linux/linux-6.6/drivers/s390/cio/chp.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *    Copyright IBM Corp. 2007, 2010
462306a36Sopenharmony_ci *    Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef S390_CHP_H
862306a36Sopenharmony_ci#define S390_CHP_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/types.h>
1162306a36Sopenharmony_ci#include <linux/device.h>
1262306a36Sopenharmony_ci#include <linux/mutex.h>
1362306a36Sopenharmony_ci#include <asm/chpid.h>
1462306a36Sopenharmony_ci#include "chsc.h"
1562306a36Sopenharmony_ci#include "css.h"
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define CHP_STATUS_STANDBY		0
1862306a36Sopenharmony_ci#define CHP_STATUS_CONFIGURED		1
1962306a36Sopenharmony_ci#define CHP_STATUS_RESERVED		2
2062306a36Sopenharmony_ci#define CHP_STATUS_NOT_RECOGNIZED	3
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define CHP_ONLINE 0
2362306a36Sopenharmony_ci#define CHP_OFFLINE 1
2462306a36Sopenharmony_ci#define CHP_VARY_ON 2
2562306a36Sopenharmony_ci#define CHP_VARY_OFF 3
2662306a36Sopenharmony_ci#define CHP_FCES_EVENT 4
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistruct chp_link {
2962306a36Sopenharmony_ci	struct chp_id chpid;
3062306a36Sopenharmony_ci	u32 fla_mask;
3162306a36Sopenharmony_ci	u16 fla;
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistatic inline int chp_test_bit(u8 *bitmap, int num)
3562306a36Sopenharmony_ci{
3662306a36Sopenharmony_ci	int byte = num >> 3;
3762306a36Sopenharmony_ci	int mask = 128 >> (num & 7);
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	return (bitmap[byte] & mask) ? 1 : 0;
4062306a36Sopenharmony_ci}
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cistruct channel_path {
4462306a36Sopenharmony_ci	struct device dev;
4562306a36Sopenharmony_ci	struct chp_id chpid;
4662306a36Sopenharmony_ci	struct mutex lock; /* Serialize access to below members. */
4762306a36Sopenharmony_ci	int state;
4862306a36Sopenharmony_ci	struct channel_path_desc_fmt0 desc;
4962306a36Sopenharmony_ci	struct channel_path_desc_fmt1 desc_fmt1;
5062306a36Sopenharmony_ci	struct channel_path_desc_fmt3 desc_fmt3;
5162306a36Sopenharmony_ci	/* Channel-measurement related stuff: */
5262306a36Sopenharmony_ci	int cmg;
5362306a36Sopenharmony_ci	int shared;
5462306a36Sopenharmony_ci	struct cmg_chars cmg_chars;
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* Return channel_path struct for given chpid. */
5862306a36Sopenharmony_cistatic inline struct channel_path *chpid_to_chp(struct chp_id chpid)
5962306a36Sopenharmony_ci{
6062306a36Sopenharmony_ci	return css_by_id(chpid.cssid)->chps[chpid.id];
6162306a36Sopenharmony_ci}
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciint chp_get_status(struct chp_id chpid);
6462306a36Sopenharmony_ciu8 chp_get_sch_opm(struct subchannel *sch);
6562306a36Sopenharmony_ciint chp_is_registered(struct chp_id chpid);
6662306a36Sopenharmony_cistruct channel_path_desc_fmt0 *chp_get_chp_desc(struct chp_id chpid);
6762306a36Sopenharmony_civoid chp_remove_cmg_attr(struct channel_path *chp);
6862306a36Sopenharmony_ciint chp_add_cmg_attr(struct channel_path *chp);
6962306a36Sopenharmony_ciint chp_update_desc(struct channel_path *chp);
7062306a36Sopenharmony_ciint chp_new(struct chp_id chpid);
7162306a36Sopenharmony_civoid chp_cfg_schedule(struct chp_id chpid, int configure);
7262306a36Sopenharmony_civoid chp_cfg_cancel_deconfigure(struct chp_id chpid);
7362306a36Sopenharmony_ciint chp_info_get_status(struct chp_id chpid);
7462306a36Sopenharmony_ciint chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *);
7562306a36Sopenharmony_ci#endif /* S390_CHP_H */
76