chpid.h 979 B

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