1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2e6b6e10aSPeter Oberparleiter /* 3b730f3a9SSebastian Ott * Copyright IBM Corp. 2007, 2010 4e6b6e10aSPeter Oberparleiter * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 5e6b6e10aSPeter Oberparleiter */ 6e6b6e10aSPeter Oberparleiter 7e6b6e10aSPeter Oberparleiter #ifndef S390_CHP_H 899ec1112SDaniel van Gerpen #define S390_CHP_H 9e6b6e10aSPeter Oberparleiter 10e6b6e10aSPeter Oberparleiter #include <linux/types.h> 11e6b6e10aSPeter Oberparleiter #include <linux/device.h> 12b730f3a9SSebastian Ott #include <linux/mutex.h> 13e5854a58SPeter Oberparleiter #include <asm/chpid.h> 14e6b6e10aSPeter Oberparleiter #include "chsc.h" 150ae7a7b2SCornelia Huck #include "css.h" 16e6b6e10aSPeter Oberparleiter 17e5854a58SPeter Oberparleiter #define CHP_STATUS_STANDBY 0 18e5854a58SPeter Oberparleiter #define CHP_STATUS_CONFIGURED 1 19e5854a58SPeter Oberparleiter #define CHP_STATUS_RESERVED 2 20e5854a58SPeter Oberparleiter #define CHP_STATUS_NOT_RECOGNIZED 3 21e5854a58SPeter Oberparleiter 22c820de39SCornelia Huck #define CHP_ONLINE 0 23c820de39SCornelia Huck #define CHP_OFFLINE 1 24c820de39SCornelia Huck #define CHP_VARY_ON 2 25c820de39SCornelia Huck #define CHP_VARY_OFF 3 2632ef9388SVineeth Vijayan #define CHP_FCES_EVENT 4 27c820de39SCornelia Huck 2899611f87SCornelia Huck struct chp_link { 29c820de39SCornelia Huck struct chp_id chpid; 30c820de39SCornelia Huck u32 fla_mask; 31c820de39SCornelia Huck u16 fla; 32c820de39SCornelia Huck }; 33c820de39SCornelia Huck chp_test_bit(u8 * bitmap,int num)34e5854a58SPeter Oberparleiterstatic inline int chp_test_bit(u8 *bitmap, int num) 35e5854a58SPeter Oberparleiter { 36e5854a58SPeter Oberparleiter int byte = num >> 3; 37e5854a58SPeter Oberparleiter int mask = 128 >> (num & 7); 38e5854a58SPeter Oberparleiter 39e5854a58SPeter Oberparleiter return (bitmap[byte] & mask) ? 1 : 0; 40e5854a58SPeter Oberparleiter } 41e5854a58SPeter Oberparleiter 42e5854a58SPeter Oberparleiter 43e6b6e10aSPeter Oberparleiter struct channel_path { 44b730f3a9SSebastian Ott struct device dev; 45e6b6e10aSPeter Oberparleiter struct chp_id chpid; 46b730f3a9SSebastian Ott struct mutex lock; /* Serialize access to below members. */ 47e6b6e10aSPeter Oberparleiter int state; 48ded27d8dSSebastian Ott struct channel_path_desc_fmt0 desc; 49cce0eaccSPeter Oberparleiter struct channel_path_desc_fmt1 desc_fmt1; 50fcc6dd4bSSebastian Ott struct channel_path_desc_fmt3 desc_fmt3; 51e6b6e10aSPeter Oberparleiter /* Channel-measurement related stuff: */ 52e6b6e10aSPeter Oberparleiter int cmg; 53e6b6e10aSPeter Oberparleiter int shared; 542dc8903aSPeter Oberparleiter int extended; 55*0f987e6cSPeter Oberparleiter unsigned long speed; 560d9bfe91SSebastian Ott struct cmg_chars cmg_chars; 57e6b6e10aSPeter Oberparleiter }; 58e6b6e10aSPeter Oberparleiter 59c38a90a3SSebastian Ott /* Return channel_path struct for given chpid. */ chpid_to_chp(struct chp_id chpid)60c38a90a3SSebastian Ottstatic inline struct channel_path *chpid_to_chp(struct chp_id chpid) 61c38a90a3SSebastian Ott { 6298cc43abSSebastian Ott return css_by_id(chpid.cssid)->chps[chpid.id]; 63c38a90a3SSebastian Ott } 64c38a90a3SSebastian Ott 65e6b6e10aSPeter Oberparleiter int chp_get_status(struct chp_id chpid); 66e6b6e10aSPeter Oberparleiter u8 chp_get_sch_opm(struct subchannel *sch); 67e6b6e10aSPeter Oberparleiter int chp_is_registered(struct chp_id chpid); 68ded27d8dSSebastian Ott struct channel_path_desc_fmt0 *chp_get_chp_desc(struct chp_id chpid); 69e6b6e10aSPeter Oberparleiter void chp_remove_cmg_attr(struct channel_path *chp); 70e6b6e10aSPeter Oberparleiter int chp_add_cmg_attr(struct channel_path *chp); 71cce0eaccSPeter Oberparleiter int chp_update_desc(struct channel_path *chp); 72e6b6e10aSPeter Oberparleiter int chp_new(struct chp_id chpid); 73e5854a58SPeter Oberparleiter void chp_cfg_schedule(struct chp_id chpid, int configure); 74e5854a58SPeter Oberparleiter void chp_cfg_cancel_deconfigure(struct chp_id chpid); 75e5854a58SPeter Oberparleiter int chp_info_get_status(struct chp_id chpid); 7699611f87SCornelia Huck int chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *); 77e6b6e10aSPeter Oberparleiter #endif /* S390_CHP_H */ 78