wlan_platform_modules.bzl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
  2. load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
  3. load("//msm-kernel:target_variants.bzl", "get_all_variants")
  4. _default_module_enablement_list = [
  5. "cnss_nl",
  6. "cnss_prealloc",
  7. "cnss_utils",
  8. "wlan_firmware_service"
  9. ]
  10. _cnss2_enabled_target = ["niobe", "pineapple", "sun"]
  11. _icnss2_enabled_target = ["blair", "pineapple", "monaco", "pitti", "volcano"]
  12. def _get_module_list(target, variant):
  13. tv = "{}_{}".format(target, variant)
  14. ret = []
  15. is_wlan_platform_enabled = False
  16. if target in _cnss2_enabled_target:
  17. ret.extend(["cnss2", "cnss_plat_ipc_qmi_svc"])
  18. is_wlan_platform_enabled = True
  19. if target in _icnss2_enabled_target:
  20. ret.extend(["icnss2"])
  21. is_wlan_platform_enabled = True
  22. if is_wlan_platform_enabled:
  23. ret.extend(_default_module_enablement_list)
  24. return [":{}_{}".format(tv, mod) for mod in ret]
  25. def _define_platform_config_rule(module, target, variant):
  26. tv = "{}_{}".format(target, variant)
  27. native.genrule(
  28. name = "{}/{}_defconfig_generate_perf".format(module, tv),
  29. outs = ["{}/{}_defconfig.generated_perf".format(module, tv)],
  30. srcs = [
  31. "{}/{}_gki_defconfig".format(module, target),
  32. ],
  33. cmd = "cat $(SRCS) > $@",
  34. )
  35. native.genrule(
  36. name = "{}/{}_defconfig_generate_gki".format(module, tv),
  37. outs = ["{}/{}_defconfig.generated_gki".format(module, tv)],
  38. srcs = [
  39. "{}/{}_gki_defconfig".format(module, target),
  40. ],
  41. cmd = "cat $(SRCS) > $@",
  42. )
  43. native.genrule(
  44. name = "{}/{}_defconfig_generate_consolidate".format(module, tv),
  45. outs = ["{}/{}_defconfig.generated_consolidate".format(module, tv)],
  46. srcs = [
  47. "{}/{}_consolidate_defconfig".format(module, target),
  48. ],
  49. cmd = "cat $(SRCS) > $@",
  50. )
  51. def _define_modules_for_target_variant(target, variant):
  52. tv = "{}_{}".format(target, variant)
  53. cnss2_enabled = 0
  54. plat_ipc_qmi_svc_enabled = 0
  55. icnss2_enabled = 0
  56. if target in _cnss2_enabled_target:
  57. cnss2_enabled = 1
  58. plat_ipc_qmi_svc_enabled = 1
  59. if target in _icnss2_enabled_target:
  60. icnss2_enabled = 1
  61. print("tv=", tv)
  62. if cnss2_enabled:
  63. module = "cnss2"
  64. _define_platform_config_rule(module, target, variant)
  65. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  66. ddk_module(
  67. name = "{}_cnss2".format(tv),
  68. srcs = native.glob([
  69. "cnss2/main.c",
  70. "cnss2/bus.c",
  71. "cnss2/debug.c",
  72. "cnss2/pci.c",
  73. "cnss2/pci_platform.h",
  74. "cnss2/power.c",
  75. "cnss2/genl.c",
  76. "cnss2/*.h",
  77. "cnss_utils/*.h",
  78. ]),
  79. includes = ["cnss", "cnss_utils"],
  80. kconfig = "cnss2/Kconfig",
  81. defconfig = defconfig,
  82. conditional_srcs = {
  83. "CONFIG_CNSS2_QMI": {
  84. True: [
  85. "cnss2/qmi.c",
  86. "cnss2/coexistence_service_v01.c",
  87. ]
  88. },
  89. "CONFIG_PCI_MSM": {
  90. True: [
  91. "cnss2/pci_qcom.c",
  92. ],
  93. },
  94. },
  95. out = "cnss2.ko",
  96. kernel_build = "//msm-kernel:{}".format(tv),
  97. deps = [
  98. "//vendor/qcom/opensource/securemsm-kernel:{}_smcinvoke_dlkm".format(tv),
  99. ":{}_cnss_utils".format(tv),
  100. ":{}_cnss_prealloc".format(tv),
  101. ":{}_wlan_firmware_service".format(tv),
  102. ":{}_cnss_plat_ipc_qmi_svc".format(tv),
  103. "//msm-kernel:all_headers",
  104. ":wlan-platform-headers",
  105. ],
  106. )
  107. if icnss2_enabled:
  108. module = "icnss2"
  109. _define_platform_config_rule(module, target, variant)
  110. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  111. ddk_module(
  112. name = "{}_icnss2".format(tv),
  113. srcs = native.glob([
  114. "icnss2/main.c",
  115. "icnss2/debug.c",
  116. "icnss2/power.c",
  117. "icnss2/genl.c",
  118. "icnss2/*.h",
  119. "cnss_utils/*.h",
  120. ]),
  121. includes = ["icnss2", "cnss_utils"],
  122. kconfig = "icnss2/Kconfig",
  123. copts = ["-Wno-format"],
  124. defconfig = defconfig,
  125. conditional_srcs = {
  126. "CONFIG_ICNSS2_QMI": {
  127. True: [
  128. "icnss2/qmi.c",
  129. ],
  130. },
  131. },
  132. out = "icnss2.ko",
  133. kernel_build = "//msm-kernel:{}".format(tv),
  134. deps = [
  135. ":{}_cnss_utils".format(tv),
  136. ":{}_cnss_prealloc".format(tv),
  137. ":{}_wlan_firmware_service".format(tv),
  138. "//msm-kernel:all_headers",
  139. ":wlan-platform-headers",
  140. ],
  141. )
  142. module = "cnss_genl"
  143. _define_platform_config_rule(module, target, variant)
  144. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  145. ddk_module(
  146. name = "{}_cnss_nl".format(tv),
  147. srcs = [
  148. "cnss_genl/cnss_nl.c",
  149. ],
  150. kconfig = "cnss_genl/Kconfig",
  151. defconfig = defconfig,
  152. out = "cnss_nl.ko",
  153. kernel_build = "//msm-kernel:{}".format(tv),
  154. deps = [
  155. "//msm-kernel:all_headers",
  156. ":wlan-platform-headers",
  157. ],
  158. )
  159. module = "cnss_prealloc"
  160. _define_platform_config_rule(module, target, variant)
  161. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  162. ddk_module(
  163. name = "{}_cnss_prealloc".format(tv),
  164. srcs = native.glob([
  165. "cnss_prealloc/cnss_prealloc.c",
  166. "cnss_utils/*.h",
  167. ]),
  168. includes = ["cnss_utils"],
  169. kconfig = "cnss_prealloc/Kconfig",
  170. defconfig = defconfig,
  171. out = "cnss_prealloc.ko",
  172. kernel_build = "//msm-kernel:{}".format(tv),
  173. deps = [
  174. "//msm-kernel:all_headers",
  175. ":wlan-platform-headers",
  176. ],
  177. )
  178. module = "cnss_utils"
  179. _define_platform_config_rule(module, target, variant)
  180. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  181. ddk_module(
  182. name = "{}_cnss_utils".format(tv),
  183. srcs = native.glob([
  184. "cnss_utils/cnss_utils.c",
  185. "cnss_utils/*.h"
  186. ]),
  187. kconfig = "cnss_utils/Kconfig",
  188. defconfig = defconfig,
  189. out = "cnss_utils.ko",
  190. kernel_build = "//msm-kernel:{}".format(tv),
  191. deps = [
  192. "//msm-kernel:all_headers",
  193. ":wlan-platform-headers",
  194. ],
  195. )
  196. module = "cnss_utils"
  197. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  198. ddk_module(
  199. name = "{}_wlan_firmware_service".format(tv),
  200. srcs = native.glob([
  201. "cnss_utils/wlan_firmware_service_v01.c",
  202. "cnss_utils/device_management_service_v01.c",
  203. "cnss_utils/ip_multimedia_subsystem_private_service_v01.c",
  204. "cnss_utils/*.h"
  205. ]),
  206. kconfig = "cnss_utils/Kconfig",
  207. defconfig = defconfig,
  208. out = "wlan_firmware_service.ko",
  209. kernel_build = "//msm-kernel:{}".format(tv),
  210. deps = ["//msm-kernel:all_headers"],
  211. )
  212. module = "cnss_utils"
  213. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  214. if plat_ipc_qmi_svc_enabled:
  215. ddk_module(
  216. name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
  217. srcs = native.glob([
  218. "cnss_utils/cnss_plat_ipc_qmi.c",
  219. "cnss_utils/cnss_plat_ipc_service_v01.c",
  220. "cnss_utils/*.h"
  221. ]),
  222. kconfig = "cnss_utils/Kconfig",
  223. defconfig = defconfig,
  224. out = "cnss_plat_ipc_qmi_svc.ko",
  225. kernel_build = "//msm-kernel:{}".format(tv),
  226. deps = ["//msm-kernel:all_headers"],
  227. )
  228. tv = "{}_{}".format(target, variant)
  229. copy_to_dist_dir(
  230. name = "{}_modules_dist".format(tv),
  231. data = _get_module_list(target, variant),
  232. dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
  233. flat = True,
  234. wipe_dist_dir = False,
  235. allow_duplicate_filenames = False,
  236. mode_overrides = {"**/*": "644"},
  237. log = "info"
  238. )
  239. def define_modules():
  240. for (t, v) in get_all_variants():
  241. print("v=", v)
  242. _define_modules_for_target_variant(t, v)