1c6557e7fSMartin Schwidefsky /* 24dcc2a4dSSebastian Ott * Copyright IBM Corp. 2007, 2012 3c6557e7fSMartin Schwidefsky * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 4c6557e7fSMartin Schwidefsky */ 5c6557e7fSMartin Schwidefsky #ifndef _ASM_S390_CHPID_H 687d2f5e3SDavid Howells #define _ASM_S390_CHPID_H 7c6557e7fSMartin Schwidefsky 89807f759SDavid Howells #include <uapi/asm/chpid.h> 9c6557e7fSMartin Schwidefsky #include <asm/cio.h> 10c6557e7fSMartin Schwidefsky 11*2bf29df7SSebastian Ott struct channel_path_desc { 12*2bf29df7SSebastian Ott u8 flags; 13*2bf29df7SSebastian Ott u8 lsn; 14*2bf29df7SSebastian Ott u8 desc; 15*2bf29df7SSebastian Ott u8 chpid; 16*2bf29df7SSebastian Ott u8 swla; 17*2bf29df7SSebastian Ott u8 zeroes; 18*2bf29df7SSebastian Ott u8 chla; 19*2bf29df7SSebastian Ott u8 chpp; 20*2bf29df7SSebastian Ott } __packed; 21*2bf29df7SSebastian Ott 22c6557e7fSMartin Schwidefsky static inline void chp_id_init(struct chp_id *chpid) 23c6557e7fSMartin Schwidefsky { 24c6557e7fSMartin Schwidefsky memset(chpid, 0, sizeof(struct chp_id)); 25c6557e7fSMartin Schwidefsky } 26c6557e7fSMartin Schwidefsky 27c6557e7fSMartin Schwidefsky static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b) 28c6557e7fSMartin Schwidefsky { 29c6557e7fSMartin Schwidefsky return (a->id == b->id) && (a->cssid == b->cssid); 30c6557e7fSMartin Schwidefsky } 31c6557e7fSMartin Schwidefsky 32c6557e7fSMartin Schwidefsky static inline void chp_id_next(struct chp_id *chpid) 33c6557e7fSMartin Schwidefsky { 34c6557e7fSMartin Schwidefsky if (chpid->id < __MAX_CHPID) 35c6557e7fSMartin Schwidefsky chpid->id++; 36c6557e7fSMartin Schwidefsky else { 37c6557e7fSMartin Schwidefsky chpid->id = 0; 38c6557e7fSMartin Schwidefsky chpid->cssid++; 39c6557e7fSMartin Schwidefsky } 40c6557e7fSMartin Schwidefsky } 41c6557e7fSMartin Schwidefsky 42c6557e7fSMartin Schwidefsky static inline int chp_id_is_valid(struct chp_id *chpid) 43c6557e7fSMartin Schwidefsky { 44c6557e7fSMartin Schwidefsky return (chpid->cssid <= __MAX_CSSID); 45c6557e7fSMartin Schwidefsky } 46c6557e7fSMartin Schwidefsky 47c6557e7fSMartin Schwidefsky 48c6557e7fSMartin Schwidefsky #define chp_id_for_each(c) \ 49c6557e7fSMartin Schwidefsky for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c)) 50c6557e7fSMartin Schwidefsky #endif /* _ASM_S390_CHPID_H */ 51