1e6b6e10aSPeter Oberparleiter /* 2b730f3a9SSebastian Ott * Copyright IBM Corp. 2007, 2010 3e6b6e10aSPeter Oberparleiter * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 4e6b6e10aSPeter Oberparleiter */ 5e6b6e10aSPeter Oberparleiter 6e6b6e10aSPeter Oberparleiter #ifndef S390_CHP_H 799ec1112SDaniel van Gerpen #define S390_CHP_H 8e6b6e10aSPeter Oberparleiter 9e6b6e10aSPeter Oberparleiter #include <linux/types.h> 10e6b6e10aSPeter Oberparleiter #include <linux/device.h> 11b730f3a9SSebastian Ott #include <linux/mutex.h> 12e5854a58SPeter Oberparleiter #include <asm/chpid.h> 13e6b6e10aSPeter Oberparleiter #include "chsc.h" 140ae7a7b2SCornelia Huck #include "css.h" 15e6b6e10aSPeter Oberparleiter 16e5854a58SPeter Oberparleiter #define CHP_STATUS_STANDBY 0 17e5854a58SPeter Oberparleiter #define CHP_STATUS_CONFIGURED 1 18e5854a58SPeter Oberparleiter #define CHP_STATUS_RESERVED 2 19e5854a58SPeter Oberparleiter #define CHP_STATUS_NOT_RECOGNIZED 3 20e5854a58SPeter Oberparleiter 21c820de39SCornelia Huck #define CHP_ONLINE 0 22c820de39SCornelia Huck #define CHP_OFFLINE 1 23c820de39SCornelia Huck #define CHP_VARY_ON 2 24c820de39SCornelia Huck #define CHP_VARY_OFF 3 25c820de39SCornelia Huck 2699611f87SCornelia Huck struct chp_link { 27c820de39SCornelia Huck struct chp_id chpid; 28c820de39SCornelia Huck u32 fla_mask; 29c820de39SCornelia Huck u16 fla; 30c820de39SCornelia Huck }; 31c820de39SCornelia Huck 32e5854a58SPeter Oberparleiter static inline int chp_test_bit(u8 *bitmap, int num) 33e5854a58SPeter Oberparleiter { 34e5854a58SPeter Oberparleiter int byte = num >> 3; 35e5854a58SPeter Oberparleiter int mask = 128 >> (num & 7); 36e5854a58SPeter Oberparleiter 37e5854a58SPeter Oberparleiter return (bitmap[byte] & mask) ? 1 : 0; 38e5854a58SPeter Oberparleiter } 39e5854a58SPeter Oberparleiter 40e5854a58SPeter Oberparleiter 41e6b6e10aSPeter Oberparleiter struct channel_path { 42b730f3a9SSebastian Ott struct device dev; 43e6b6e10aSPeter Oberparleiter struct chp_id chpid; 44b730f3a9SSebastian Ott struct mutex lock; /* Serialize access to below members. */ 45e6b6e10aSPeter Oberparleiter int state; 46e6b6e10aSPeter Oberparleiter struct channel_path_desc desc; 47cce0eaccSPeter Oberparleiter struct channel_path_desc_fmt1 desc_fmt1; 48e6b6e10aSPeter Oberparleiter /* Channel-measurement related stuff: */ 49e6b6e10aSPeter Oberparleiter int cmg; 50e6b6e10aSPeter Oberparleiter int shared; 510d9bfe91SSebastian Ott struct cmg_chars cmg_chars; 52e6b6e10aSPeter Oberparleiter }; 53e6b6e10aSPeter Oberparleiter 54c38a90a3SSebastian Ott /* Return channel_path struct for given chpid. */ 55c38a90a3SSebastian Ott static inline struct channel_path *chpid_to_chp(struct chp_id chpid) 56c38a90a3SSebastian Ott { 57*98cc43abSSebastian Ott return css_by_id(chpid.cssid)->chps[chpid.id]; 58c38a90a3SSebastian Ott } 59c38a90a3SSebastian Ott 60e6b6e10aSPeter Oberparleiter int chp_get_status(struct chp_id chpid); 61e6b6e10aSPeter Oberparleiter u8 chp_get_sch_opm(struct subchannel *sch); 62e6b6e10aSPeter Oberparleiter int chp_is_registered(struct chp_id chpid); 632bf29df7SSebastian Ott struct channel_path_desc *chp_get_chp_desc(struct chp_id chpid); 64e6b6e10aSPeter Oberparleiter void chp_remove_cmg_attr(struct channel_path *chp); 65e6b6e10aSPeter Oberparleiter int chp_add_cmg_attr(struct channel_path *chp); 66cce0eaccSPeter Oberparleiter int chp_update_desc(struct channel_path *chp); 67e6b6e10aSPeter Oberparleiter int chp_new(struct chp_id chpid); 68e5854a58SPeter Oberparleiter void chp_cfg_schedule(struct chp_id chpid, int configure); 69e5854a58SPeter Oberparleiter void chp_cfg_cancel_deconfigure(struct chp_id chpid); 70e5854a58SPeter Oberparleiter int chp_info_get_status(struct chp_id chpid); 7199611f87SCornelia Huck int chp_ssd_get_mask(struct chsc_ssd_info *, struct chp_link *); 72e6b6e10aSPeter Oberparleiter #endif /* S390_CHP_H */ 73