Prechádzať zdrojové kódy

cnss2: Support the Bazel DDK

Android builds are transitioning to using Bazel for builds, and there
is a Driver Development Kit (DDK) which out-of-tree drivers must use
in this new scheme. Introduce the infrastructure to describe the wlan
platform driver modules using the DDK.

Change-Id: Ied2aae354aaea8a038461f6c74f26fe4f362a05a
CRs-Fixed: 3449426
Jeff Johnson 2 rokov pred
rodič
commit
4ae0fef4d3

+ 34 - 0
BUILD.bazel

@@ -0,0 +1,34 @@
+load("//build/kernel/kleaf:kernel.bzl", "ddk_headers")
+load(":wlan_platform_modules.bzl", "define_modules")
+
+
+package(
+    default_visibility = [
+        "//visibility:public",
+    ],
+)
+
+ddk_headers(
+    name = "wlan-platform-headers",
+    hdrs = glob([
+        "inc/*.h",
+    ]),
+    includes = ["inc"],
+)
+
+ddk_headers(
+    name = "wlan-platform-private-headers",
+    hdrs = glob([
+        "cnss2/*.h",
+        "cnss_utils/*.h",
+        "icnss2/*.h"
+    ]),
+    includes = ["cnss2", "cnss_utils", "icnss2"],
+)
+
+ddk_headers(
+    name = "all-wlan-platform-headers",
+    hdrs = [":wlan-platform-headers", ":wlan-platform-private-headers"],
+)
+
+define_modules()

+ 12 - 0
build/pineapple_consolidate_defconfig

@@ -0,0 +1,12 @@
+CONFIG_CNSS2=y
+CONFIG_CNSS_OUT_OF_TREE=y
+CONFIG_CNSS2_QMI=y
+CONFIG_CNSS_QMI_SVC=y
+CONFIG_CNSS_GENL=y
+CONFIG_BUS_AUTO_SUSPEND=y
+CONFIG_CNSS2_SSR_DRIVER_DUMP=y
+CONFIG_CNSS_HW_SECURE_DISABLE=y
+CONFIG_CNSS2_SMMU_DB_SUPPORT=y
+CONFIG_CNSS_PLAT_IPC_QMI_SVC=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CNSS_UTILS=y

+ 12 - 0
build/pineapple_gki_defconfig

@@ -0,0 +1,12 @@
+CONFIG_CNSS2=y
+CONFIG_CNSS_OUT_OF_TREE=y
+CONFIG_CNSS2_QMI=y
+CONFIG_CNSS_QMI_SVC=y
+CONFIG_CNSS_GENL=y
+CONFIG_BUS_AUTO_SUSPEND=y
+CONFIG_CNSS2_SSR_DRIVER_DUMP=y
+CONFIG_CNSS_HW_SECURE_DISABLE=y
+CONFIG_CNSS2_SMMU_DB_SUPPORT=y
+CONFIG_CNSS_PLAT_IPC_QMI_SVC=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CNSS_UTILS=y

+ 5 - 0
cnss_genl/Kconfig

@@ -7,3 +7,8 @@ config CNSS_GENL
 	  used by cld driver and userspace utilities to communicate over
 	  netlink sockets. This module creates different multicast groups to
 	  facilitate the same.
+
+config CNSS_OUT_OF_TREE
+	bool "Build module out-of-tree"
+	help
+	  This enables building the module out of the main kernel tree

+ 5 - 0
cnss_prealloc/Kconfig

@@ -7,3 +7,8 @@ config WCNSS_MEM_PRE_ALLOC
 	  This feature enable cld wlan driver to use pre allocated memory
 	  for it's internal usage and release it to back to pre allocated pool.
 	  This memory is allocated at the cold boot time.
+
+config CNSS_OUT_OF_TREE
+	bool "Build module out-of-tree"
+	help
+	  This enables building the module out of the main kernel tree

+ 5 - 0
cnss_utils/Kconfig

@@ -18,3 +18,8 @@ config CNSS_PLAT_IPC_QMI_SVC
 	tristate "CNSS Platform QMI IPC Support"
 	help
 	  Add CNSS platform kernel and user space components IPC using QMI.
+
+config CNSS_OUT_OF_TREE
+	bool "Build module out-of-tree"
+	help
+	  This enables building the module out of the main kernel tree

+ 192 - 0
wlan_platform_modules.bzl

@@ -0,0 +1,192 @@
+load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
+load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
+load("//msm-kernel:target_variants.bzl", "get_all_variants")
+
+_module_enablement_map = {
+    # "ALL" will enable for all target/variant combos
+    "cnss2": ["ALL"],
+    # Empty list disables the module build
+    "icnss2": [],
+    "cnss_nl": ["ALL"],
+    "cnss_prealloc": ["ALL"],
+    # List specific target/variants if needed
+    "cnss_utils": [
+        "pineapple_consolidate",
+    ],
+    "wlan_firmware_service": ["ALL"],
+    "cnss_plat_ipc_qmi_svc": ["ALL"],
+}
+
+def _get_module_list(target, variant):
+    tv = "{}_{}".format(target, variant)
+
+    ret = []
+    for (mod, enabled_platforms) in _module_enablement_map.items():
+        if "ALL" in enabled_platforms or tv in enabled_platforms:
+            ret.append(mod)
+            continue
+
+    return [":{}_{}".format(tv, mod) for mod in ret]
+
+
+def _define_modules_for_target_variant(target, variant):
+    tv = "{}_{}".format(target, variant)
+
+    ddk_module(
+        name = "{}_cnss2".format(tv),
+        srcs = native.glob([
+            "cnss2/main.c",
+            "cnss2/bus.c",
+            "cnss2/debug.c",
+            "cnss2/pci.c",
+            "cnss2/pci_platform.h",
+            "cnss2/power.c",
+            "cnss2/genl.c",
+            "cnss2/*.h",
+            "cnss_utils/*.h",
+        ]),
+        includes = ["cnss", "cnss_utils"],
+        kconfig = "cnss2/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        conditional_srcs =  {
+            "CONFIG_CNSS2_QMI": {
+                True: [
+                    "cnss2/qmi.c",
+                    "cnss2/coexistence_service_v01.c",
+                    "cnss2/ip_multimedia_subsystem_private_service_v01.c",
+                ]
+            },
+            "CONFIG_PCI_MSM": {
+                True: [
+                    "cnss2/pci_qcom.c",
+                ],
+            },
+        },
+        out = "cnss2.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = [
+            "//vendor/qcom/opensource/securemsm-kernel:{}_smcinvoke_dlkm".format(tv),
+            ":{}_cnss_utils".format(tv),
+            ":{}_wlan_firmware_service".format(tv),
+            ":{}_cnss_plat_ipc_qmi_svc".format(tv),
+            "//msm-kernel:all_headers",
+            ":wlan-platform-headers",
+        ],
+    )
+
+    ddk_module(
+        name = "{}_icnss2".format(tv),
+        srcs = native.glob([
+            "icnss2/main.c",
+            "icnss2/debug.c",
+            "icnss2/power.c",
+            "icnss2/genl.c",
+            "icnss2/*.h",
+            "cnss_utils/*.h",
+        ]),
+        includes = ["icnss2", "cnss_utils"],
+        kconfig = "icnss2/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        conditional_srcs = {
+            "CONFIG_ICNSS2_QMI": {
+                True: [
+                    "icnss2/qmi.c",
+                ],
+            },
+        },
+        out = "icnss2.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = [
+            "//msm-kernel:all_headers",
+            ":wlan-platform-headers",
+        ],
+    )
+
+    ddk_module(
+        name = "{}_cnss_nl".format(tv),
+        srcs = [
+            "cnss_genl/cnss_nl.c",
+        ],
+        kconfig = "cnss_genl/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        out = "cnss_nl.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = [
+            "//msm-kernel:all_headers",
+            ":wlan-platform-headers",
+        ],
+    )
+
+    ddk_module(
+        name = "{}_cnss_prealloc".format(tv),
+        srcs = [
+            "cnss_prealloc/cnss_prealloc.c",
+        ],
+        kconfig = "cnss_prealloc/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        out = "cnss_prealloc.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = [
+            "//msm-kernel:all_headers",
+            ":wlan-platform-headers",
+        ],
+    )
+
+    ddk_module(
+        name = "{}_cnss_utils".format(tv),
+        srcs = native.glob([
+            "cnss_utils/cnss_utils.c",
+            "cnss_utils/*.h"
+        ]),
+        kconfig = "cnss_utils/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        out = "cnss_utils.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = [
+            "//msm-kernel:all_headers",
+            ":wlan-platform-headers",
+        ],
+    )
+
+    ddk_module(
+        name = "{}_wlan_firmware_service".format(tv),
+        srcs = native.glob([
+            "cnss_utils/wlan_firmware_service_v01.c",
+            "cnss_utils/device_management_service_v01.c",
+            "cnss_utils/*.h"
+        ]),
+        kconfig = "cnss_utils/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        out = "wlan_firmware_service.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = ["//msm-kernel:all_headers"],
+    )
+
+    ddk_module(
+        name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
+        srcs = native.glob([
+            "cnss_utils/cnss_plat_ipc_qmi.c",
+            "cnss_utils/cnss_plat_ipc_service_v01.c",
+            "cnss_utils/*.h"
+        ]),
+        kconfig = "cnss_utils/Kconfig",
+        defconfig = "build/{}_defconfig".format(tv),
+        out = "cnss_plat_ipc_qmi_svc.ko",
+        kernel_build = "//msm-kernel:{}".format(tv),
+        deps = ["//msm-kernel:all_headers"],
+    )
+
+    copy_to_dist_dir(
+        name = "{}_modules_dist".format(tv),
+        data = _get_module_list(target, variant),
+        dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
+        flat = True,
+        wipe_dist_dir = False,
+        allow_duplicate_filenames = False,
+        mode_overrides = {"**/*": "644"},
+        log = "info"
+    )
+
+def define_modules():
+    for (t, v) in get_all_variants():
+        _define_modules_for_target_variant(t, v)