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