18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright IBM Corp. 2007, 2010 48c2ecf20Sopenharmony_ci * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef S390_CHP_H 88c2ecf20Sopenharmony_ci#define S390_CHP_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/types.h> 118c2ecf20Sopenharmony_ci#include <linux/device.h> 128c2ecf20Sopenharmony_ci#include <linux/mutex.h> 138c2ecf20Sopenharmony_ci#include <asm/chpid.h> 148c2ecf20Sopenharmony_ci#include "chsc.h" 158c2ecf20Sopenharmony_ci#include "css.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define CHP_STATUS_STANDBY 0 188c2ecf20Sopenharmony_ci#define CHP_STATUS_CONFIGURED 1 198c2ecf20Sopenharmony_ci#define CHP_STATUS_RESERVED 2 208c2ecf20Sopenharmony_ci#define CHP_STATUS_NOT_RECOGNIZED 3 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define CHP_ONLINE 0 238c2ecf20Sopenharmony_ci#define CHP_OFFLINE 1 248c2ecf20Sopenharmony_ci#define CHP_VARY_ON 2 258c2ecf20Sopenharmony_ci#define CHP_VARY_OFF 3 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct chp_link { 288c2ecf20Sopenharmony_ci struct chp_id chpid; 298c2ecf20Sopenharmony_ci u32 fla_mask; 308c2ecf20Sopenharmony_ci u16 fla; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic inline int chp_test_bit(u8 *bitmap, int num) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci int byte = num >> 3; 368c2ecf20Sopenharmony_ci int mask = 128 >> (num & 7); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci return (bitmap[byte] & mask) ? 1 : 0; 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct channel_path { 438c2ecf20Sopenharmony_ci struct device dev; 448c2ecf20Sopenharmony_ci struct chp_id chpid; 458c2ecf20Sopenharmony_ci struct mutex lock; /* Serialize access to below members. */ 468c2ecf20Sopenharmony_ci int state; 478c2ecf20Sopenharmony_ci struct channel_path_desc_fmt0 desc; 488c2ecf20Sopenharmony_ci struct channel_path_desc_fmt1 desc_fmt1; 498c2ecf20Sopenharmony_ci struct channel_path_desc_fmt3 desc_fmt3; 508c2ecf20Sopenharmony_ci /* Channel-measurement related stuff: */ 518c2ecf20Sopenharmony_ci int cmg; 528c2ecf20Sopenharmony_ci int shared; 538c2ecf20Sopenharmony_ci struct cmg_chars cmg_chars; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Return channel_path struct for given chpid. */ 578c2ecf20Sopenharmony_cistatic inline struct channel_path *chpid_to_chp(struct chp_id chpid) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci return css_by_id(chpid.cssid)->chps[chpid.id]; 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciint chp_get_status(struct chp_id chpid); 638c2ecf20Sopenharmony_ciu8 chp_get_sch_opm(struct subchannel *sch); 648c2ecf20Sopenharmony_ciint chp_is_registered(struct chp_id chpid); 658c2ecf20Sopenharmony_cistruct channel_path_desc_fmt0 *chp_get_chp_desc(struct chp_id chpid); 668c2ecf20Sopenharmony_civoid chp_remove_cmg_attr(struct channel_path *chp); 678c2ecf20Sopenharmony_ciint chp_add_cmg_attr(struct channel_path *chp); 688c2ecf20Sopenharmony_ciint chp_update_desc(struct channel_path *chp); 698c2ecf20Sopenharmony_ciint chp_new(struct chp_id chpid); 708c2ecf20Sopenharmony_civoid chp_cfg_schedule(struct chp_id chpid, int configure); 718c2ecf20Sopenharmony_civoid chp_cfg_cancel_deconfigure(struct chp_id chpid); 728c2ecf20Sopenharmony_ciint chp_info_get_status(struct chp_id chpid); 738c2ecf20Sopenharmony_ciint chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *); 748c2ecf20Sopenharmony_ci#endif /* S390_CHP_H */ 75