halcc: Remove hal dependency scheme from manifest 19/311019/3
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 3 May 2024 08:53:42 +0000 (17:53 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 13 May 2024 05:49:58 +0000 (14:49 +0900)
It is currently not used. And for support multi-versioning hal manifest,
the current style should be totally reformed somehow. Therefore, removed
the hal dependency scheme and related operations.

Change-Id: I1857b558f6debc9463fb3babfbc1447326dfc4bb
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/hal-api-compatibility-checker-object.c
src/hal-api-compatibility-checker-object.h
src/hal-api-compatibility-checker-parser.c
src/hal-api-compatibility-checker.c
tests/unittest/test-hal-compatibility-checker.cc

index 9715c4496696d6be4e3ab26b41dc9570d22686d6..d327425713b1bd81e968018fd4935324595910cd 100644 (file)
@@ -44,8 +44,6 @@ typedef struct halcc_hal {
        char *name;
        halcc_version version;
        halcc_transport_e transport;
-       halcc_dependency_state_e dependency_state;
-       GHashTable *dependencies;
        GHashTable *interfaces;
 } halcc_hal;
 
@@ -589,194 +587,6 @@ void halcc_manifest_foreach_hal(halcc_manifest *manifest,
        hashtable_foreach(manifest->hals, cb, user_data);
 }
 
-static void reset_hal_dependency_state(void *data, void *user_data)
-{
-       halcc_hal *hal = (halcc_hal *) data;
-
-       assert(hal);
-
-       halcc_hal_set_dependency_state(hal, HALCC_DEPENDENCY_STATE_NONE);
-}
-
-/**
- * Check whether the dependencies specified by hal->dependencies are satisfied.
- * It sets hal->dependency_state and returns the value.
- */
-static halcc_dependency_state_e
-__validate_hal_dependency_state(halcc_manifest *manifest, halcc_hal *hal)
-{
-       halcc_hal *dependency;
-       halcc_dependency_state_e state = HALCC_DEPENDENCY_STATE_FAIL;
-       GHashTableIter iter;
-
-       assert(manifest);
-       assert(hal);
-
-       halcc_hal_get_dependency_state(hal, &state);
-
-       /* It has been checked already, return immediately. */
-       if (state != HALCC_DEPENDENCY_STATE_NONE)
-               return state;
-
-       /**
-        * Mark it as validating is underway.
-        *
-        * The dependency_state will eventually be changed into
-        * HALCC_DEPENDENCY_STATE_SUCCESS or HALCC_DEPENDENCY_STATE_FAIL
-        * before going out of this function.
-        */
-       halcc_hal_set_dependency_state(hal, HALCC_DEPENDENCY_STATE_VALIDATING);
-
-       /**
-        * As the hashtable_foreach() only accepts a single parameter, it is
-        * annoying that passing multiple parameter to iteration callback.
-        * So exceptionally iterate the hashtable directly instead of using
-        * hashtable_foreach().
-        *
-        * Iterate over the dependencies of the given hal. Check if there is compatible
-        * hal with that dependency in the manifest. It will success only when all of the given
-        * dependencies is compatible with one of a hal from the manifest. Otherwise, resolution
-        * fails, setting dependency_state to HALCC_DEPENDENCY_STATE_FAIL.
-        */
-       g_hash_table_iter_init(&iter, hal->dependencies);
-       while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &dependency)) {
-               const char *dependency_hal_name = NULL;
-               int dependency_hal_major = 0;
-               int dependency_hal_minor = 0;
-               halcc_hal *found = NULL;
-               int ret;
-
-               halcc_hal_get_name(dependency, &dependency_hal_name);
-               halcc_hal_get_version(dependency, &dependency_hal_major, &dependency_hal_minor);
-
-               ret = halcc_manifest_find_hal_forward_compatible(manifest,
-                       dependency_hal_name, dependency_hal_major, dependency_hal_minor,
-                       &found);
-               if (ret != 0) { /* There is no hal that meets dependency. */
-                       halcc_hal_set_dependency_state(hal, HALCC_DEPENDENCY_STATE_FAIL);
-                       return HALCC_DEPENDENCY_STATE_FAIL;
-               }
-
-               /* Recursively validate dependency of the found hal. */
-               state = __validate_hal_dependency_state(manifest, found);
-
-               assert(state != HALCC_DEPENDENCY_STATE_NONE);
-
-               if (state == HALCC_DEPENDENCY_STATE_SUCCESS)
-                       continue;
-
-               /**
-                * The below two cases are possible and they are all regarded as failure.
-                *
-                * 1) state == HALCC_DEPENDENCY_STATE_FAIL
-                *     : The found hal has already failed to validate its dependency,
-                *       thus the current hal is also set to fail.
-                *
-                * 2) state == HALCC_DEPENDENCY_STATE_VALIDATING
-                *     : Cyclic dependency, fail.
-                */
-               halcc_hal_set_dependency_state(hal, HALCC_DEPENDENCY_STATE_FAIL);
-
-               return HALCC_DEPENDENCY_STATE_FAIL;
-       }
-
-       halcc_hal_set_dependency_state(hal, HALCC_DEPENDENCY_STATE_SUCCESS);
-
-       return HALCC_DEPENDENCY_STATE_SUCCESS;
-}
-
-static void validate_hal_dependency_state(void *data, void *user_data)
-{
-       halcc_manifest *manifest;
-       halcc_hal *hal;
-
-       manifest = (halcc_manifest *) user_data;
-       hal = (halcc_hal *) data;
-
-       assert(manifest);
-       assert(hal);
-
-       __validate_hal_dependency_state(manifest, hal);
-}
-
-/**
- * Validate dependencies between hals within manifest.
- *
- * Let's say a manifest contains below specification about 4 hals
- *  - AAA@1.5  : success
- *  - BBB@2.3  : success
- *  - CCC@3.3  : success
- *  - DDD@1.0  : success
- * If there are no dependencies between each other, no problem.
- *
- * Case1] If AAA@1.5 depends on YYY@1.0.
- *  - AAA@1.5 -> YYY@1.0  : fail, YYY@1.0 is not specified
- *  - BBB@2.3  : success
- *  - CCC@3.3  : success
- *  - DDD@1.0  : success
- *
- * Case2] If AAA@1.5 depends on BBB@1.0.
- *  - AAA@1.5 -> BBB@1.0  : fail, BBB@1.0 isn't compatible with
- *                          the specified BBB@2.3
- *  - BBB@2.3  : success
- *  - CCC@3.3  : success
- *  - DDD@1.0  : success
- *
- * Caser3] If AAA@1.5 depends on BBB@2.0, CCC@4.0
- *  - AAA@1.5 -> BBB@2.0, CCC@4.0 : fail, BBB@2.0 is backward compatible
- *                          with the specified BBB@2.3, but CCC@4.0 isn't
- *                          compatible with the specified CCC@3.3.
- *  - BBB@2.3  : success
- *  - CCC@3.3  : success
- *  - DDD@1.0  : success
- *  If multiple dependencies are specified, it success only when all the
- *  dependencies are satisfied.
- *
- * Case4] If AAA@1.5 depends on BBB@2.0
- *           and BBB@2.3 depends on CCC@3.0
- *           and CCC@3.3 depends on DDD@1.5
- *  - AAA@1.5 -> BBB@2.0  : fail, BBB@2.0 is backward compatible with the
- *                          specified BBB@2.3, but BBB@2.3 has failed to
- *                          validate dependency
- *  - BBB@2.3 -> CCC@3.0  : fail, CCC@3.0 is backward compatible with the
- *                          specified CCC@3.3, but CCC@3.3 has failed to
- *                          validate dependency
- *  - CCC@3.3 -> DDD@1.5  : fail, DDD@1.5 isn't compatible with the
- *                          specified DDD@1.0
- *  - DDD@1.0  : success
- *  The failure is propagated to all hals that have dependency on that
- *  failed hal.
- *
- * Case5] If AAA@1.5 depends on BBB@2.1
- *           and BBB@2.3 depends on CCC@3.0
- *           and CCC@3.3 depends on AAA@1.0
- *  - AAA@1.5 -> BBB@2.1  : fail, cyclic dependency
- *  - BBB@2.3 -> CCC@3.0  : fail, cyclic dependency
- *  - CCC@3.3 -> AAA@1.0  : fail, cyclic dependency
- *  - DDD@1.0  : success
- *  All hals that make dependency cycle are failure.
- *
- * Case6] If AAA@1.5 depends on BBB@2.0
- *           and BBB@2.3 depends on CCC@3.0
- *  - AAA@1.5 -> BBB@2.0  : success
- *  - BBB@2.3 -> CCC@3.0  : success
- *  - CCC@3.3  : success
- *  - DDD@1.0  : success
- */
-void halcc_manifest_validate_hal_dependency(halcc_manifest *manifest)
-{
-       if (!manifest) {
-               printf("Invalid parameter\n");
-               return;
-       }
-
-       /* Reset all */
-       halcc_manifest_foreach_hal(manifest, reset_hal_dependency_state, NULL);
-
-       /* Validate dependency */
-       halcc_manifest_foreach_hal(manifest, validate_hal_dependency_state, manifest);
-}
-
 int halcc_hal_new(halcc_hal **hal)
 {
        halcc_hal *h;
@@ -793,8 +603,6 @@ int halcc_hal_new(halcc_hal **hal)
        }
 
        h->transport = HALCC_TRANSPORT_DEFAULT;
-       h->dependency_state = HALCC_DEPENDENCY_STATE_NONE;
-       h->dependencies = hashtable_hal_new();
        h->interfaces = hashtable_interface_new();
 
        *hal = g_steal_pointer(&h);
@@ -810,7 +618,6 @@ void halcc_hal_free(halcc_hal *hal)
        }
 
        free(g_steal_pointer(&hal->name));
-       g_hash_table_destroy(g_steal_pointer(&hal->dependencies));
        g_hash_table_destroy(g_steal_pointer(&hal->interfaces));
        free(hal);
 }
@@ -906,37 +713,6 @@ int halcc_hal_get_transport(halcc_hal *hal, halcc_transport_e *transport)
        return 0;
 }
 
-int halcc_hal_add_dependency(halcc_hal *hal, halcc_hal *dependency)
-{
-       if (!hal || !dependency) {
-               printf("Invalid parameter\n");
-               return -EINVAL;
-       }
-
-       return hashtable_hal_insert(hal->dependencies, dependency);
-}
-
-void halcc_hal_remove_dependency(halcc_hal *hal,
-       const char *dependency_hal_name, int major, int minor)
-{
-       if (!hal || !dependency_hal_name) {
-               printf("Invalid parameter\n");
-               return;
-       }
-
-       hashtable_hal_remove(hal->dependencies, dependency_hal_name, major, minor);
-}
-
-void halcc_hal_foreach_dependency(halcc_hal *hal, halcc_iter_cb cb, void *user_data)
-{
-       if (!hal || !hal->dependencies || !cb) {
-               printf("Invalid parameter\n");
-               return;
-       }
-
-       hashtable_foreach(hal->dependencies, cb, user_data);
-}
-
 int halcc_hal_add_interface(halcc_hal *hal, halcc_interface *interface)
 {
        if (!hal || !interface) {
@@ -968,30 +744,6 @@ void halcc_hal_foreach_interface(halcc_hal *hal, halcc_iter_cb cb, void *user_da
        hashtable_foreach(hal->interfaces, cb, user_data);
 }
 
-int halcc_hal_set_dependency_state(halcc_hal *hal, halcc_dependency_state_e dependency_state)
-{
-       if (!hal) {
-               printf("Invalid parameter\n");
-               return -EINVAL;
-       }
-
-       hal->dependency_state = dependency_state;
-
-       return 0;
-}
-
-int halcc_hal_get_dependency_state(halcc_hal *hal, halcc_dependency_state_e *dependency_state)
-{
-       if (!hal || !dependency_state) {
-               printf("Invalid parameter\n");
-               return -EINVAL;
-       }
-
-       *dependency_state = hal->dependency_state;
-
-       return 0;
-}
-
 int halcc_interface_new(halcc_interface **interface)
 {
        halcc_interface *iface;
index c5d22adae3457b35e4de4ae1496c559daab85c40..bfd9f60023365cfad2e2597a29369395acbf6cb2 100644 (file)
@@ -36,13 +36,6 @@ typedef enum halcc_transport_e {
        HALCC_TRANSPORT_IPC,
 } halcc_transport_e;
 
-typedef enum halcc_dependency_state_e {
-       HALCC_DEPENDENCY_STATE_NONE = 0,
-       HALCC_DEPENDENCY_STATE_VALIDATING,
-       HALCC_DEPENDENCY_STATE_SUCCESS,
-       HALCC_DEPENDENCY_STATE_FAIL,
-} halcc_dependency_state_e;
-
 typedef struct halcc_manifest halcc_manifest;
 typedef struct halcc_hal halcc_hal;
 typedef struct halcc_interface halcc_interface;
@@ -78,7 +71,6 @@ void halcc_manifest_remove_hal(halcc_manifest *manifest,
        const char *hal_name, int major, int minor);
 void halcc_manifest_foreach_hal(halcc_manifest *manifest,
        halcc_iter_cb cb, void *user_data);
-void halcc_manifest_validate_hal_dependency(halcc_manifest *manifest);
 
 int halcc_hal_new(halcc_hal **hal);
 void halcc_hal_free(halcc_hal *hal);
@@ -88,16 +80,10 @@ int halcc_hal_set_version(halcc_hal *hal, int major, int minor);
 int halcc_hal_get_version(halcc_hal *hal, int *major, int *minor);
 int halcc_hal_set_transport(halcc_hal *hal, halcc_transport_e transport);
 int halcc_hal_get_transport(halcc_hal *hal, halcc_transport_e *transport);
-int halcc_hal_add_dependency(halcc_hal *hal, halcc_hal *dependency);
-void halcc_hal_remove_dependency(halcc_hal *hal,
-       const char *dependency_hal_name, int major, int minor);
-void halcc_hal_foreach_dependency(halcc_hal *hal, halcc_iter_cb cb, void *user_data);
 int halcc_hal_add_interface(halcc_hal *hal, halcc_interface *interface);
 void halcc_hal_remove_interface(halcc_hal *hal,
        const char *interface_name, const char *instance_id);
 void halcc_hal_foreach_interface(halcc_hal *hal, halcc_iter_cb cb, void *user_data);
-int halcc_hal_set_dependency_state(halcc_hal *hal, halcc_dependency_state_e dependency_state);
-int halcc_hal_get_dependency_state(halcc_hal *hal, halcc_dependency_state_e *dependency_state);
 
 int halcc_interface_new(halcc_interface **interface);
 void halcc_interface_free(halcc_interface *interface);
index 50f1a4cd4f9baa4a77b2193c1c726815ba0d23f5..1075c784972094a5f2a94c835843251ab690833e 100644 (file)
@@ -121,27 +121,6 @@ static int parse_hal(xmlNode *node, halcc_hal *hal)
 
                        halcc_hal_add_interface(hal, iface);
                        iface = NULL;
-               } else if (xmlStrEqual(child->name, "dependency")) {
-                       for (xmlNode *grand_child = child->children; grand_child; grand_child = grand_child->next) {
-                               halcc_hal *h;
-
-                               if (!xmlStrEqual(grand_child->name, "hal"))
-                                       continue;
-
-                               ret = halcc_hal_new(&h);
-                               if (ret != 0)
-                                       continue;
-
-                               ret = parse_hal(grand_child, h);
-                               if (ret != 0) {
-                                       halcc_hal_free(h);
-                                       h = NULL;
-                                       continue;
-                               }
-
-                               halcc_hal_add_dependency(hal, h);
-                               h = NULL;
-                       }
                }
        }
 
index 4a618f68a23fa2dd76ed401cfd45323eb307aae3..56fce9487fbd39604b70454201d1d1d8475ef628 100644 (file)
@@ -150,12 +150,6 @@ static void make_compatibility_manifest_info(void *data, void *user_data)
        halcc_hal *hal;
        const char *hal_name = NULL;
        int manifest_major, manifest_minor;
-       /**
-        * FIXME:
-        * Temporarily disable dependency checking. See the below FIXME.
-        *
-        * halcc_dependency_state_e state;
-        */
        int ret;
        const char *error_desc = NULL;
        struct compatibility_info *manifest_info = NULL;
@@ -186,21 +180,6 @@ static void make_compatibility_manifest_info(void *data, void *user_data)
                return;
        }
 
-       /**
-        * FIXME:
-        * Temporarily disable it. For now, it is unclear that
-        * this dependency checking is necessary. Because, those hal-api
-        * header and manifest.xml aren't managed by ACR process so they
-        * could be transformed anyhow, breaking dependency. Currently,
-        * our policy has no such specification that force them to think
-        * about and comply with dependency among hal-apis.
-        *
-        * if (halcc_hal_get_dependency_state(hal, &state) != 0) {
-        *      error_desc = "Failed to resolve dependency";
-        *      goto out;
-        * }
-        */
-
        if (halcc_hal_get_version(hal, &manifest_major, &manifest_minor) < 0) {
                error_desc = "Invalid manifest version";
                goto out;
@@ -381,18 +360,6 @@ static int load_hal_manifest(struct compatibility_info *manifest_info, int load_
        if (ret < 0)
                goto out;
 
-       /**
-        * FIXME:
-        * Temporarily disable it. For now, it is unclear that
-        * this dependency checking is necessary. Because, those hal-api
-        * header and manifest.xml aren't managed by ACR process so they
-        * could be transformed anyhow, breaking dependency. Currently,
-        * our policy has no such specification that force them to think
-        * about and comply with dependency among hal-apis.
-        *
-        * halcc_manifest_validate_hal_dependency(manifest);
-        */
-
        halcc_manifest_foreach_hal(manifest, make_compatibility_manifest_info, manifest_info);
 
        g_compatibility_manifest_info_loaded = true;
index 8864b0976cc78a4b670a1efa2b089883e4cb1900..914c58942e702586f224e1a0ead82e3ca2bdd835 100644 (file)
@@ -33,24 +33,6 @@ static char g_manifest_xml[] =
 "                      <interface>"
 "                              <name>hal_backend_device_display_data</name>"
 "                      </interface>"
-"                      <dependency>"
-"                              <hal>"
-"                                      <name>hal.device.board</name>"
-"                                      <version>1.0</version>"
-"                                      <transport>passthrough</transport>"
-"                                      <interface>"
-"                                              <name>hal_backend_device_board_data</name>"
-"                                      </interface>"
-"                              </hal>"
-"                              <hal>"
-"                                      <name>hal.tdm</name>"
-"                                      <version>1.0</version>"
-"                                      <transport>passthrough</transport>"
-"                                      <interface>"
-"                                              <name>hal_backend_tdm_data</name>"
-"                                      </interface>"
-"                              </hal>"
-"                      </dependency>"
 "              </hal>"
 "              <hal>"
 "                      <name>hal.something</name>"