thermal-engine: Add support for bandwidth client API to receive two data

Add support for bandwidth request API to receive two input data
(bw_score and usecase_id) from clients using the same API.

Add new thermal bandwidth client helper API to combine two type of
bandwidth input data into single 32 bit int value. Client can use
this utility API for merging two inputs prior to every bandwidth
request to thermal/limits module.

Validate multi inputs from client from both thermal client library
and thermal server side before using it.

Remove tab characters from thermal client header file.

Client needs to consider below points for using bandwidth client APIs

- Whenever client wants to update bandwidth vote to limits, use this
helper API, 'thermal_bandwidth_client_merge_input_info()' first to
merge two input data into single int variable and the return value
will be used as final bandwidth request value for API,
'thermal_bandwidth_client_request()' with client name.

- 1st 16 bit will be used for bandwidth utilization score and 2nd
16 bits will be used for usecase_id.

- Both input data should be a maximum of 15 bit positive integer.
More than 15 bit data will be treat as invalid bandwidth data.

- Default value for both bandwidth input data will be zero. So client
should not use zero as a valid use case id or bandwidth score.

- It is client responsibility to pass current value of both inputs
anytime. If one of the input changes, client needs to send latest
value for both the inputs. The limits code will always consider last
requested value for both inputs.

- On first client request call, thermal library code will create few
resources for sending data and server death monitor. It will re-use
the same resource on subsequent calls. It is clients responsibility to
invoke 'thermal_bandwidth_client_cancel_request()' API to release all
these resources once client is done with bandwidth request update or
on exit.

Change-Id: I7afe80812434cfef6fe568e59e8beda5bdc8fddc
diff --git a/thermal_client.h b/thermal_client.h
index 93eea81..b8f0ca2 100644
--- a/thermal_client.h
+++ b/thermal_client.h
@@ -39,48 +39,48 @@
 
 /* Enum for supported fields */
 enum supported_fields {
-	UNKNOWN_FIELD = 0x0,
-	DISABLE_FIELD = 0x1,
-	SAMPLING_FIELD = 0x2,
-	POLLING_DELAY_FIELD = SAMPLING_FIELD,
-	THRESHOLDS_FIELD = 0x4,
-	SET_POINT_FIELD = THRESHOLDS_FIELD,
-	THRESHOLDS_CLR_FIELD = 0x8,
-	SET_POINT_CLR_FIELD = THRESHOLDS_CLR_FIELD,
-	ACTION_INFO_FIELD = 0x10,
-	UPPER_LIMIT_FIELD = ACTION_INFO_FIELD,
-	LOWER_LIMIT_FIELD = 0x20,
-	PASSIVE_DELAY_FIELD = 0x40,
-	SUPPORTED_FIELD_MAX = 0x80,
+        UNKNOWN_FIELD = 0x0,
+        DISABLE_FIELD = 0x1,
+        SAMPLING_FIELD = 0x2,
+        POLLING_DELAY_FIELD = SAMPLING_FIELD,
+        THRESHOLDS_FIELD = 0x4,
+        SET_POINT_FIELD = THRESHOLDS_FIELD,
+        THRESHOLDS_CLR_FIELD = 0x8,
+        SET_POINT_CLR_FIELD = THRESHOLDS_CLR_FIELD,
+        ACTION_INFO_FIELD = 0x10,
+        UPPER_LIMIT_FIELD = ACTION_INFO_FIELD,
+        LOWER_LIMIT_FIELD = 0x20,
+        PASSIVE_DELAY_FIELD = 0x40,
+        SUPPORTED_FIELD_MAX = 0x80,
 };
 
 enum field_data_type {
-	FIELD_INT = 0,
-	FIELD_STR,
-	FIELD_INT_ARR,
-	FIELD_ARR_STR,
-	FIELD_ARR_INT_ARR,
-	FIELD_MAX
+        FIELD_INT = 0,
+        FIELD_STR,
+        FIELD_INT_ARR,
+        FIELD_ARR_STR,
+        FIELD_ARR_INT_ARR,
+        FIELD_MAX
 };
 
 struct action_info_data {
-	int info[MAX_ACTIONS];
-	uint32_t num_actions;
+        int info[MAX_ACTIONS];
+        uint32_t num_actions;
 };
 
 struct field_data {
-	char *field_name;
-	enum field_data_type data_type;
-	uint32_t num_data;
-	void *data;
+        char *field_name;
+        enum field_data_type data_type;
+        uint32_t num_data;
+        void *data;
 };
 
 struct config_instance {
-	char *cfg_desc;
-	char *algo_type;
-	unsigned int fields_mask;  /* mask set by client to request to adjust supported fields */
-	uint32_t num_fields;
-	struct field_data *fields;
+        char *cfg_desc;
+        char *algo_type;
+        unsigned int fields_mask;  /* mask set by client to request to adjust supported fields */
+        uint32_t num_fields;
+        struct field_data *fields;
 };
 
 int thermal_client_config_query(char *algo_type, struct config_instance **configs);
@@ -95,6 +95,16 @@
 int thermal_bandwidth_client_request(char *client_name, int req_data);
 void thermal_bandwidth_client_cancel_request(char *client_name);
 
+/* Inline API to combine two 15 bit bw inputs into single int variable and return the same */
+static inline int thermal_bandwidth_client_merge_input_info(int bw_score, int uc_id)
+{
+        if (bw_score < 0 || bw_score > 0x7fff ||
+                uc_id < 0 || uc_id > 0x7fff)
+                return -1;
+
+        return (((uc_id & 0x7fff) << 0x10) | (bw_score & 0x7fff));
+}
+
 #ifdef __cplusplus
 }
 #endif