-
Notifications
You must be signed in to change notification settings - Fork 96
RDKB-61190:[OneWifi] Implemented HE bus async method invoke API #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
RDKB-61190:[OneWifi] Implemented HE bus async method invoke API #541
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also please list the testing (various unit test scenarios) addressed as part of this change?
source/platform/common/bus_common.c
Outdated
{ | ||
bus_data_prop_t *next; | ||
|
||
if (p_data_prop->ref_count <= 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be just == 1. If it goes below 1 it should already have been freed right and should not do anything.
source/platform/common/bus_common.c
Outdated
free_bus_raw_data(&p_data_prop->value); | ||
p_data_prop->is_data_set = false; | ||
p_data_prop->ref_count = 0; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should explicitly check for > 1 for this.
source/platform/common/bus_common.c
Outdated
|
||
while(p_data_prop) { | ||
next = p_data_prop->next_data; | ||
if (p_data_prop->ref_count <= 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above everywhere ref_count is used.
source/platform/common/bus_common.c
Outdated
p_data_prop->ref_count--; | ||
} | ||
|
||
while(p_data_prop) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand what is the usecase of if above and then a while loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe above if can be folded in the while loop.
source/platform/common/bus_common.c
Outdated
p_data_prop->is_data_set = false; | ||
p_data_prop->ref_count = 0; | ||
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p already have some references:%d\r\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p already have some references:%d\r\n", | |
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p still have some references:%d\r\n", |
source/platform/common/bus_common.c
Outdated
while(p_data_prop) { | ||
next = p_data_prop->next_data; | ||
if (p_data_prop->ref_count <= 1) { | ||
free_bus_raw_data(&p_data_prop->value); | ||
free(p_data_prop); | ||
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p already have some references:%d\r\n", | ||
__func__, __LINE__, p_data_prop, p_data_prop->ref_count); | ||
p_data_prop->ref_count--; | ||
} | ||
p_data_prop = next; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while(p_data_prop) { | |
next = p_data_prop->next_data; | |
if (p_data_prop->ref_count <= 1) { | |
free_bus_raw_data(&p_data_prop->value); | |
free(p_data_prop); | |
} else { | |
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p already have some references:%d\r\n", | |
__func__, __LINE__, p_data_prop, p_data_prop->ref_count); | |
p_data_prop->ref_count--; | |
} | |
p_data_prop = next; | |
} | |
next = p_data_prop->next_data; | |
while(next) { | |
if (next->ref_count <= 1) { | |
bus_data_prop_t *temp_next = next; | |
next = next->next_data; | |
free_bus_raw_data(&temp_next->value); | |
free(temp_next); | |
if (prev) { | |
prev->next_data = NULL; | |
} | |
} else { | |
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p still have some references:%d\r\n", | |
__func__, __LINE__, next, next->ref_count); | |
next->ref_count--; | |
if (!first) { | |
first = next; | |
} | |
if (prev) { | |
prev->next_data = next; | |
} | |
prev = next; | |
next = next->next_data; | |
++*num_prop; | |
} | |
} | |
return first; |
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p already have some references:%d\r\n", | ||
__func__, __LINE__, p_data_prop, p_data_prop->ref_count); | ||
p_data_prop->ref_count--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p_data_prop->ref_count--; | |
p_data_prop->ref_count--; | |
first = p_data_prop; | |
prev = p_data_prop; | |
++*num_prop; |
source/platform/common/bus_common.c
Outdated
void bus_release_data_prop(bus_data_prop_t *p_data_prop) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void bus_release_data_prop(bus_data_prop_t *p_data_prop) | |
{ | |
bus_data_prop_t *bus_release_data_prop(bus_data_prop_t *p_data_prop, int *num_prop) | |
{ | |
*num_prop = 0; | |
bus_data_prop_t *first = NULL; | |
bus_data_prop_t *prev = NULL; |
source/platform/common/bus_common.c
Outdated
bus_release_data_prop(&p_bus_obj->data_prop); | ||
p_bus_obj->num_prop = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bus_release_data_prop(&p_bus_obj->data_prop); | |
p_bus_obj->num_prop = 0; | |
p_bus_obj->data_prop = *bus_release_data_prop(&p_bus_obj->data_prop, &p_bus_obj->num_prop); |
return NULL; | ||
} | ||
|
||
he_bus_error_t he_bus_async_method_invoke(he_bus_handle_t handle, char const *event_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add declaration of this function to header file.
source/platform/openwrt/bus.c
Outdated
@@ -201,6 +201,12 @@ static bus_error_t bus_remove_table_row(bus_handle_t *handle, char const *name) | |||
return bus_error_success; | |||
} | |||
|
|||
bus_error_t bus_method_async_invoke(bus_handle_t *handle, void *param_name, char *event_name, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/platform/rdkb/bus.c
Outdated
@@ -1796,6 +1796,12 @@ static bus_error_t bus_remove_table_row(bus_handle_t *handle, char const *name) | |||
return convert_rbus_to_bus_error_code(rc); | |||
} | |||
|
|||
bus_error_t bus_method_async_invoke(bus_handle_t *handle, void *param_name, char *event_name, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/platform/common/bus_common.h
Outdated
typedef bus_error_t (* wifi_bus_reg_table_row_t) (bus_handle_t *handle, char const *name, uint32_t row_index, char const *alias); | ||
typedef bus_error_t (* wifi_bus_unreg_table_row_t) (bus_handle_t *handle, char const *name); | ||
typedef bus_error_t (* wifi_bus_add_table_row_t) (bus_handle_t *handle, char const *name, char const *alias, uint32_t *row_index); | ||
typedef bus_error_t (* wifi_bus_remove_table_row_t) (bus_handle_t *handle, char const *name); | ||
typedef bus_error_t (* wifi_bus_unreg_elements_t) (bus_handle_t *handle, uint32_t num_of_element, bus_data_element_t *data_element); | ||
typedef bus_error_t (* wifi_bus_method_invoke_t) (bus_handle_t *handle, void *paramName, char *event, raw_data_t *input_data, raw_data_t *output_data, uint8_t input_bus_data); | ||
typedef bus_error_t (* wifi_bus_method_async_invoke_t) (bus_handle_t *handle, void *param_name, char *event_name, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/platform/common/bus_common.h
Outdated
@@ -218,13 +252,14 @@ typedef bus_error_t (* wifi_bus_event_subscribe_ex_async_t) (bus_handle_t *h | |||
typedef bus_error_t (* wifi_bus_event_unsubscribe_t) (bus_handle_t *handle, char const* event_name); | |||
typedef bus_error_t (* wifi_bus_event_unsubs_ex_t) (bus_handle_t *handle, bus_event_sub_t *l_sub_info_map, int num_sub); | |||
typedef bus_error_t (* wifi_bus_reg_elements_t) (bus_handle_t *handle, bus_data_element_t *data_element, uint32_t num_of_element); | |||
typedef bus_error_t (* wifi_bus_method_invoke_t) (bus_handle_t *handle, void *paramName, char *event, raw_data_t *input_data, raw_data_t *output_data, uint8_t input_bus_data); | |||
typedef bus_error_t (* wifi_bus_method_invoke_t) (bus_handle_t *handle, void *paramName, char *event, bus_data_obj_t *input_data, bus_data_obj_t *output_data, uint8_t input_bus_data); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/platform/common/bus_common.h
Outdated
typedef bus_error_t (*bus_name_sub_handler_t)(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); | ||
|
||
typedef bus_error_t (*bus_event_sub_handler_t)(char *event_name, raw_data_t *p_data, void *userData); | ||
typedef bus_error_t (*bus_event_sub_ex_async_handler_t)(char *event_name, bus_error_t ret, void *userData); | ||
|
||
typedef void (* wifi_bus_method_async_resp_handler_t) (char const* methodName, bus_error_t error, bus_data_prop_t *params, void *userData); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
l_obj = he_bus_calloc(1, sizeof(he_bus_data_object_t)); | ||
|
||
l_obj = memory_alloc_for_he_bus_data_obj(); | ||
HE_BUS_CHECK_NULL_WITH_RC(l_obj, he_bus_error_out_of_resources); | ||
l_obj->next_data = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already null, calloc does that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so no need for this line:
l_obj->next_data = NULL;
@@ -486,16 +517,29 @@ void free_raw_data_struct(he_bus_raw_data_t *p_data) | |||
|
|||
void free_bus_msg_obj_data(he_bus_data_object_t *p_obj_data) | |||
{ | |||
free_raw_data_struct(&p_obj_data->data); | |||
if (p_obj_data->ref_count <= 1) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
uint32_t get_max_objs_cnt(he_bus_data_object_t *p_objs) | ||
{ | ||
uint32_t total_obj_size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_obj_cnt. variable suggests something other than function name,.
return total_obj_size; | ||
} | ||
|
||
int set_obj_status(he_bus_data_object_t *p_objs, he_bus_error_t ret_status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this will always return OK, void or _Noreturn ( <stdnoreturn.h> from c11) seems more appropriate
|
||
while(index < 3) { | ||
payload_data.data_type = he_bus_data_type_uint32; | ||
payload_data.raw_data.u32 = index + 11; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is test code only. So, I added this number for testing.
0043130
to
bfd2333
Compare
return temp; | ||
} | ||
|
||
int bus_data_prop_retain(bus_data_prop_t *p_prop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you're not, int bus_set_raw_data_prop(
line 899-900:
p_bus_prop->is_data_set = true;
bus_data_prop_retain(p_bus_prop);
source/platform/common/bus_common.c
Outdated
cur->ref_count--; | ||
prev = cur; | ||
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p not have some references:%d\r\n", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p not have some references:%d\r\n", | ||
__func__, __LINE__, cur, cur->ref_count); | ||
prev = cur; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you've checked that 'cur' basically doesnt exist, shouldn't this be prev = next?. if it has ref_count = 0, this is error scenario and other members (such as next_data) might not exactly be whats you expect them to be..
__func__, __LINE__, p_obj_data, p_obj_data->ref_count); | ||
p_obj_data->ref_count--; | ||
} else { | ||
he_bus_core_info_print("%s:%d memory:%p not have some references:%d\r\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in bus_Common.c this is an error scenario, update log level please.
cur->ref_count--; | ||
prev = cur; | ||
} else { | ||
he_bus_core_info_print("%s:%d memory:%p not have some references:%d\r\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as in bus_Common.c . Error level + think about rationale of prev = cur.
BUS_CHECK_NULL_WITH_RC(p_bus_prop, RETURN_ERR); | ||
BUS_CHECK_NULL_WITH_RC(p_raw_data, RETURN_ERR); | ||
|
||
if (event_name == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since most of the events will have name (correct me if im wrong), this would benefit from order change. If's are compiled with assumption to be taken, so
if (event_name != NULL) {
....
} else {
*p_raw_data = p_bus_prop->value;
}
will be more optimal here,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a name isn't provided, we should return the first element. That's why I did this.
source/platform/common/bus_common.c
Outdated
cur->ref_count--; | ||
prev = cur; | ||
} else { | ||
wifi_util_info_print(WIFI_BUS,"%s:%d memory:%p not have some references:%d\r\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of wifi_util_info_print, put this as a wifi_util_error_print
Reason for change: Implemented the HE bus asynchronous method invoke API to asynchronously set and get data between a consumer and a producer. Test Procedure: 1) Load Linux(RPI) or OpenWRT(BPI) HE bus Build. 2) Trigger "bus_method_async_invoke" API from code to test those changes. 3) Verify device memory. Risks: Low Priority: P1 Signed-off-by: [email protected]
bfd2333
to
de9c544
Compare
Reason for change: Implemented the HE bus asynchronous method invoke
API to asynchronously set and get data between a
consumer and a producer.
Test Procedure: 1) Load Linux(RPI) or OpenWRT(BPI) HE bus Build. 2) Trigger "bus_method_async_invoke" API from code to test those changes. 3) Verify device memory.
Risks: Low
Priority: P1
Signed-off-by: [email protected]