1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2c6557e7fSMartin Schwidefsky /* 34dcc2a4dSSebastian Ott * Copyright IBM Corp. 2007, 2012 4c6557e7fSMartin Schwidefsky * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 5c6557e7fSMartin Schwidefsky */ 6c6557e7fSMartin Schwidefsky #ifndef _ASM_S390_CHPID_H 787d2f5e3SDavid Howells #define _ASM_S390_CHPID_H 8c6557e7fSMartin Schwidefsky 99807f759SDavid Howells #include <uapi/asm/chpid.h> 10c6557e7fSMartin Schwidefsky #include <asm/cio.h> 11c6557e7fSMartin Schwidefsky 12*ded27d8dSSebastian Ott struct channel_path_desc_fmt0 { 132bf29df7SSebastian Ott u8 flags; 142bf29df7SSebastian Ott u8 lsn; 152bf29df7SSebastian Ott u8 desc; 162bf29df7SSebastian Ott u8 chpid; 172bf29df7SSebastian Ott u8 swla; 182bf29df7SSebastian Ott u8 zeroes; 192bf29df7SSebastian Ott u8 chla; 202bf29df7SSebastian Ott u8 chpp; 212bf29df7SSebastian Ott } __packed; 222bf29df7SSebastian Ott 23c6557e7fSMartin Schwidefsky static inline void chp_id_init(struct chp_id *chpid) 24c6557e7fSMartin Schwidefsky { 25c6557e7fSMartin Schwidefsky memset(chpid, 0, sizeof(struct chp_id)); 26c6557e7fSMartin Schwidefsky } 27c6557e7fSMartin Schwidefsky 28c6557e7fSMartin Schwidefsky static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b) 29c6557e7fSMartin Schwidefsky { 30c6557e7fSMartin Schwidefsky return (a->id == b->id) && (a->cssid == b->cssid); 31c6557e7fSMartin Schwidefsky } 32c6557e7fSMartin Schwidefsky 33c6557e7fSMartin Schwidefsky static inline void chp_id_next(struct chp_id *chpid) 34c6557e7fSMartin Schwidefsky { 35c6557e7fSMartin Schwidefsky if (chpid->id < __MAX_CHPID) 36c6557e7fSMartin Schwidefsky chpid->id++; 37c6557e7fSMartin Schwidefsky else { 38c6557e7fSMartin Schwidefsky chpid->id = 0; 39c6557e7fSMartin Schwidefsky chpid->cssid++; 40c6557e7fSMartin Schwidefsky } 41c6557e7fSMartin Schwidefsky } 42c6557e7fSMartin Schwidefsky 43c6557e7fSMartin Schwidefsky static inline int chp_id_is_valid(struct chp_id *chpid) 44c6557e7fSMartin Schwidefsky { 45c6557e7fSMartin Schwidefsky return (chpid->cssid <= __MAX_CSSID); 46c6557e7fSMartin Schwidefsky } 47c6557e7fSMartin Schwidefsky 48c6557e7fSMartin Schwidefsky 49c6557e7fSMartin Schwidefsky #define chp_id_for_each(c) \ 50c6557e7fSMartin Schwidefsky for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c)) 51c6557e7fSMartin Schwidefsky #endif /* _ASM_S390_CHPID_H */ 52