Skip to content
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

Tdi operations and notifications #126

Merged
merged 13 commits into from
Sep 12, 2023
63 changes: 63 additions & 0 deletions include/tdi/common/c_frontend/tdi_notifications.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright(c) 2023 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this software except as stipulated in the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file tdi_notifications.h
*
* @brief Contains TDI Table notifications APIs
*/
#ifndef _TDI_NOTIFICATIONS_H
#define _TDI_NOTIFICATIONS_H

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*tdi_notification_callback)(
const tdi_table_key_hdl *key,
const tdi_table_data_hdl *data,
const tdi_notification_param_hdl *params,
void *cookie);

tdi_status_t tdi_notifications_set_value(
tdi_notification_param_hdl *notifications_hdl,
const tdi_id_t field_id,
const uint64_t value);

tdi_status_t tdi_notifications_set_value_array(
tdi_notification_param_hdl *notifications_hdl,
const tdi_id_t field_id,
const uint64_t *value,
const uint32_t array_sz);

tdi_status_t tdi_notifications_get_value(
const tdi_notification_param_hdl *notifications_hdl,
const tdi_id_t field_id,
uint64_t *value);

tdi_status_t tdi_notifications_get_value_array_size(
const tdi_notification_param_hdl *notification_hdl,
const tdi_id_t field_id,
uint32_t *array_size);

tdi_status_t tdi_notifications_get_value_array(
const tdi_notification_param_hdl *notification_hdl,
const tdi_id_t field_id,
uint64_t *val);

#ifdef __cplusplus
}
#endif

#endif // _TDI_NOTIFICATIONS_H
2 changes: 1 addition & 1 deletion include/tdi/common/c_frontend/tdi_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extern "C" {
#endif

tdi_status_t tdi_operations_set_value(tdi_operations_hdl operations,
tdi_status_t tdi_operations_set_value(tdi_operations_hdl *operations,
satish153 marked this conversation as resolved.
Show resolved Hide resolved
tdi_operations_field_type_e type,
const uint64_t value);

Expand Down
26 changes: 25 additions & 1 deletion include/tdi/common/c_frontend/tdi_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

#include <tdi/common/c_frontend/tdi_attributes.h>
#include <tdi/common/c_frontend/tdi_operations.h>
#include <tdi/common/c_frontend/tdi_notifications.h>
#include <tdi/common/c_frontend/tdi_table_data.h>
#include <tdi/common/c_frontend/tdi_table_key.h>
#include <tdi/common/tdi_defs.h>
// #include <tdi/common/tdi_notifications.hpp>
satish153 marked this conversation as resolved.
Show resolved Hide resolved

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -781,9 +783,31 @@ tdi_status_t tdi_operations_deallocate(tdi_operations_hdl *tbl_op_hdl);
*
* @return Status of the API call
*/
tdi_status_t tdi_table_operations_execute(const tdi_table_hdl *table_hdl,
tdi_status_t tdi_operations_execute(const tdi_table_hdl *table_hdl,
const tdi_target_hdl *target,
const tdi_operations_hdl *tbl_ops);

tdi_status_t tdi_notifications_registration_params_allocate(
const tdi_table_hdl *table_hdl, const tdi_id_t notification_id,
tdi_notification_param_hdl **tbl_notification_hdl);

tdi_status_t tdi_notifications_registration_params_deallocate(
tdi_notification_param_hdl *tbl_notification_hdl);

tdi_status_t tdi_notifications_register(
const tdi_table_hdl *table_hdl,
const tdi_target_hdl *target,
const tdi_id_t notification_id,
const tdi_notification_callback callback_fn,
const tdi_notification_param_hdl *tbl_notification_hdl,
void *cookie);

tdi_status_t tdi_notifications_deregister(
const tdi_table_hdl *table_hdl,
const tdi_target_hdl *target,
const tdi_id_t notification_id,
const tdi_notification_param_hdl *tbl_notification_hdl);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 10 additions & 0 deletions include/tdi/common/c_frontend/tdi_table_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,16 @@ tdi_status_t tdi_table_operations_supported(
tdi_operations_type_e *operations,
uint32_t *num_returned);


tdi_status_t tdi_table_num_notifications_supported(
const tdi_table_info_hdl *table_info_hdl, uint32_t *num);

tdi_status_t tdi_table_notifications_supported(
const tdi_table_info_hdl *table_info_hdl,
// tdi_notifications_type_e *notifications,
const char *notifications[],
uint32_t *num_returned);

/**
* @brief Get size of list of tables that the given table is dependent on
*
Expand Down
9 changes: 9 additions & 0 deletions include/tdi/common/tdi_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ enum tdi_operations_field_type_e {
};
typedef enum tdi_operations_field_type_e tdi_operations_field_type_e;

enum tdi_notifications_type_e {
TDI_NOTIFICATIONS_TYPE_CORE = 0,
TDI_NOTIFICATIONS_TYPE_ARCH = 0x08,
TDI_NOTIFICATIONS_TYPE_DEVICE = 0x80,
};
typedef enum tdi_notifications_type_e tdi_notifications_type_e;


/** Identifies an error code. */
typedef int tdi_status_t;

Expand Down Expand Up @@ -328,6 +336,7 @@ DECLARE_HANDLE(tdi_learn_info_hdl);
DECLARE_HANDLE(tdi_learn_field_info_hdl);
DECLARE_HANDLE(tdi_operations_hdl);
DECLARE_HANDLE(tdi_dev_config_hdl);
DECLARE_HANDLE(tdi_notification_param_hdl);

/**
* @brief learn_data_hdl and table_data_hdl are the same,
Expand Down
11 changes: 11 additions & 0 deletions include/tdi/common/tdi_json_parser/tdi_info_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ const std::string LEARN_ID = "id";
const std::string LEARN_ANNOTATIONS = "annotations";
const std::string LEARN_FIELDS = "fields";

const std::string TABLE_NOTIFICATIONS = "notifications";
const std::string TABLE_NOTIFICATIONS_ID = "id";
const std::string TABLE_NOTIFICATIONS_NAME = "name";
const std::string TABLE_NOTIFICATIONS_REPEATED = "repeated";
const std::string TABLE_NOTIFICATIONS_MANDATORY = "mandatory";
const std::string TABLE_NOTIFICATIONS_ANNOTATIONS = "annotations";
const std::string TABLE_NOTIFICATIONS_REGISTRATION_PARAMS = "registration_params";
const std::string TABLE_NOTIFICATIONS_CALLBACK_PARAMS = "callback_params";

} // namespace tdi_json

// Forward declarations
Expand Down Expand Up @@ -104,6 +113,8 @@ class TdiInfoParser {
std::unique_ptr<DataFieldInfo> parseDataField(const tdi::Cjson &data_json,
const uint64_t &oneof_index);
std::unique_ptr<ActionInfo> parseAction(const tdi::Cjson &action_json);
std::unique_ptr<NotificationInfo> parseNotificationInfo(const tdi::Cjson &notification_json);
std::unique_ptr<NotificationParamInfo> parseNotificationParams(const tdi::Cjson &notification_param_json);
std::set<tdi::Annotation> parseAnnotations(
const tdi::Cjson &annotation_cjson);
void parseFieldWidth(const tdi::Cjson &node,
Expand Down
Loading
Loading