cfg_define.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: APIs and macros for defining configuration.
  20. */
  21. #ifndef __CFG_DEFINE_H
  22. #define __CFG_DEFINE_H
  23. enum cfg_fallback_behavior {
  24. CFG_VALUE_OR_CLAMP,
  25. CFG_VALUE_OR_DEFAULT,
  26. };
  27. #define rm_parens(...) __VA_ARGS__
  28. #define __CFG(id, mtype, args...) __CFG_##mtype(id, mtype, args)
  29. #define _CFG(id, args) __CFG(id, args)
  30. #define CFG(id) _CFG(__##id, rm_parens id)
  31. #define __CFG_INT(args...) __CFG_ANY(args)
  32. #define __CFG_UINT(args...) __CFG_ANY(args)
  33. #define __CFG_BOOL(args...) __CFG_ANY(args)
  34. #define __CFG_STRING(args...) __CFG_ANY(args)
  35. #define __CFG_MAC(args...) __CFG_ANY(args)
  36. #define __CFG_IPV4(args...) __CFG_ANY(args)
  37. #define __CFG_IPV6(args...) __CFG_ANY(args)
  38. #define __CFG_ANY(args...) (args)
  39. #define __CFG_NONE(args...)
  40. /* configuration available in ini */
  41. #define CFG_INI_INT(name, min, max, def, fallback, desc) \
  42. (INT, int32_t, name, min, max, fallback, desc, def)
  43. #define CFG_INI_UINT(name, min, max, def, fallback, desc) \
  44. (UINT, uint32_t, name, min, max, fallback, desc, def)
  45. #define CFG_INI_BOOL(name, def, desc) \
  46. (BOOL, bool, name, -1, -1, -1, desc, def)
  47. #define CFG_INI_STRING(name, min_len, max_len, def, desc) \
  48. (STRING, char *, name, min_len, max_len, -1, desc, def)
  49. #define CFG_INI_MAC(name, def, desc) \
  50. (MAC, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
  51. #define CFG_INI_IPV4(name, def, desc) \
  52. (IPV4, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
  53. #define CFG_INI_IPV6(name, def, desc) \
  54. (IPV6, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
  55. /* configuration *not* available in ini */
  56. #define CFG_INT(name, min, max, def, fallback, desc) \
  57. (NONE, int32_t, name, min, max, fallback, desc, def)
  58. #define CFG_UINT(name, min, max, def, fallback, desc) \
  59. (NONE, uint32_t, name, min, max, fallback, desc, def)
  60. #define CFG_BOOL(name, def, desc) \
  61. (NONE, bool, name, -1, -1, -1, desc, def)
  62. #define CFG_STRING(name, min_len, max_len, def, desc) \
  63. (NONE, char *, name, min_len, max_len, -1, desc, def)
  64. #define CFG_MAC(name, def, desc) \
  65. (NONE, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
  66. #define CFG_IPV4(name, def, desc) \
  67. (NONE, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
  68. #define CFG_IPV6(name, def, desc) \
  69. (NONE, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
  70. /* utility macros/functions */
  71. #ifdef MCL
  72. #define MCL_OR_WIN_VALUE(mcl_value, win_value) mcl_value
  73. #else
  74. #define MCL_OR_WIN_VALUE(mcl_value, win_value) win_value
  75. #endif
  76. #endif /* __CFG_DEFINE_H */