|
| 1 | +#ifndef __SAI_VS__ |
| 2 | +#define __SAI_VS__ |
| 3 | + |
| 4 | +#include <mutex> |
| 5 | +#include <unordered_map> |
| 6 | + |
| 7 | +#include "stdint.h" |
| 8 | +#include "stdio.h" |
| 9 | + |
| 10 | +extern "C" { |
| 11 | +#include "sai.h" |
| 12 | +} |
| 13 | +#include "saiserialize.h" |
| 14 | +#include "saiattributelist.h" |
| 15 | + |
| 16 | +#include "swss/logger.h" |
| 17 | + |
| 18 | +extern service_method_table_t g_services; |
| 19 | + |
| 20 | +extern uint64_t g_real_id; |
| 21 | + |
| 22 | +typedef std::unordered_map<std::string, std::string> AttrHash; |
| 23 | +typedef std::unordered_map<std::string, AttrHash> ObjectHash; |
| 24 | + |
| 25 | +// first key is serialized object ID (object id, vlan, route, neighbor, fdb) |
| 26 | +// value is hash containing attributes |
| 27 | +// second key is serialized attribute ID for given object |
| 28 | +// value is serialized attribute value |
| 29 | +extern ObjectHash g_objectHash; |
| 30 | + |
| 31 | +extern std::recursive_mutex g_recursive_mutex; |
| 32 | + |
| 33 | +extern const sai_acl_api_t vs_acl_api; |
| 34 | +extern const sai_buffer_api_t vs_buffer_api; |
| 35 | +extern const sai_fdb_api_t vs_fdb_api; |
| 36 | +extern const sai_hash_api_t vs_hash_api; |
| 37 | +extern const sai_hostif_api_t vs_host_interface_api; |
| 38 | +extern const sai_lag_api_t vs_lag_api; |
| 39 | +extern const sai_mirror_api_t vs_mirror_api; |
| 40 | +extern const sai_neighbor_api_t vs_neighbor_api; |
| 41 | +extern const sai_next_hop_api_t vs_next_hop_api; |
| 42 | +extern const sai_next_hop_group_api_t vs_next_hop_group_api; |
| 43 | +extern const sai_policer_api_t vs_policer_api; |
| 44 | +extern const sai_port_api_t vs_port_api; |
| 45 | +extern const sai_qos_map_api_t vs_qos_map_api; |
| 46 | +extern const sai_queue_api_t vs_queue_api; |
| 47 | +extern const sai_route_api_t vs_route_api; |
| 48 | +extern const sai_router_interface_api_t vs_router_interface_api; |
| 49 | +extern const sai_samplepacket_api_t vs_samplepacket_api; |
| 50 | +extern const sai_scheduler_api_t vs_scheduler_api; |
| 51 | +extern const sai_scheduler_group_api_t vs_scheduler_group_api; |
| 52 | +extern const sai_stp_api_t vs_stp_api; |
| 53 | +extern const sai_switch_api_t vs_switch_api; |
| 54 | +extern const sai_tunnel_api_t vs_tunnel_api; |
| 55 | +extern const sai_udf_api_t vs_udf_api; |
| 56 | +extern const sai_virtual_router_api_t vs_router_api; |
| 57 | +extern const sai_vlan_api_t vs_vlan_api; |
| 58 | +extern const sai_wred_api_t vs_wred_api; |
| 59 | + |
| 60 | +extern sai_switch_notification_t vs_switch_notifications; |
| 61 | + |
| 62 | +#define UNREFERENCED_PARAMETER(X) |
| 63 | + |
| 64 | +void translate_rid_to_vid( |
| 65 | + _In_ sai_object_type_t object_type, |
| 66 | + _In_ uint32_t attr_count, |
| 67 | + _In_ sai_attribute_t *attr_list); |
| 68 | + |
| 69 | +// separate methods are needed for vlan to not confuse with object_id |
| 70 | + |
| 71 | +sai_status_t vs_generic_create( |
| 72 | + _In_ sai_object_type_t object_type, |
| 73 | + _Out_ sai_object_id_t* object_id, |
| 74 | + _In_ uint32_t attr_count, |
| 75 | + _In_ const sai_attribute_t *attr_list); |
| 76 | + |
| 77 | +sai_status_t vs_generic_create( |
| 78 | + _In_ sai_object_type_t object_type, |
| 79 | + _In_ const sai_fdb_entry_t *fdb_entry, |
| 80 | + _In_ uint32_t attr_count, |
| 81 | + _In_ const sai_attribute_t *attr_list); |
| 82 | + |
| 83 | +sai_status_t vs_generic_create( |
| 84 | + _In_ sai_object_type_t object_type, |
| 85 | + _In_ const sai_neighbor_entry_t* neighbor_entry, |
| 86 | + _In_ uint32_t attr_count, |
| 87 | + _In_ const sai_attribute_t *attr_list); |
| 88 | + |
| 89 | +sai_status_t vs_generic_create( |
| 90 | + _In_ sai_object_type_t object_type, |
| 91 | + _In_ const sai_unicast_route_entry_t* unicast_route_entry, |
| 92 | + _In_ uint32_t attr_count, |
| 93 | + _In_ const sai_attribute_t *attr_list); |
| 94 | + |
| 95 | +sai_status_t vs_generic_create_vlan( |
| 96 | + _In_ sai_object_type_t object_type, |
| 97 | + _In_ sai_vlan_id_t vlan_id); |
| 98 | + |
| 99 | + |
| 100 | +sai_status_t vs_generic_remove( |
| 101 | + _In_ sai_object_type_t object_type, |
| 102 | + _In_ sai_object_id_t object_id); |
| 103 | + |
| 104 | +sai_status_t vs_generic_remove( |
| 105 | + _In_ sai_object_type_t object_type, |
| 106 | + _In_ const sai_fdb_entry_t* fdb_entry); |
| 107 | + |
| 108 | +sai_status_t vs_generic_remove( |
| 109 | + _In_ sai_object_type_t object_type, |
| 110 | + _In_ const sai_neighbor_entry_t* neighbor_entry); |
| 111 | + |
| 112 | +sai_status_t vs_generic_remove( |
| 113 | + _In_ sai_object_type_t object_type, |
| 114 | + _In_ const sai_unicast_route_entry_t* unicast_route_entry); |
| 115 | + |
| 116 | +sai_status_t vs_generic_remove_vlan( |
| 117 | + _In_ sai_object_type_t object_type, |
| 118 | + _In_ sai_vlan_id_t vlan_id); |
| 119 | + |
| 120 | + |
| 121 | +sai_status_t vs_generic_set( |
| 122 | + _In_ sai_object_type_t object_type, |
| 123 | + _In_ sai_object_id_t object_id, |
| 124 | + _In_ const sai_attribute_t *attr); |
| 125 | + |
| 126 | +sai_status_t vs_generic_set( |
| 127 | + _In_ sai_object_type_t object_type, |
| 128 | + _In_ const sai_fdb_entry_t *fdb_entry, |
| 129 | + _In_ const sai_attribute_t *attr); |
| 130 | + |
| 131 | +sai_status_t vs_generic_set( |
| 132 | + _In_ sai_object_type_t object_type, |
| 133 | + _In_ const sai_neighbor_entry_t* neighbor_entry, |
| 134 | + _In_ const sai_attribute_t *attr); |
| 135 | + |
| 136 | +sai_status_t vs_generic_set( |
| 137 | + _In_ sai_object_type_t object_type, |
| 138 | + _In_ const sai_unicast_route_entry_t* unicast_route_entry, |
| 139 | + _In_ const sai_attribute_t *attr); |
| 140 | + |
| 141 | +sai_status_t vs_generic_set_vlan( |
| 142 | + _In_ sai_object_type_t object_type, |
| 143 | + _In_ sai_vlan_id_t vlan_id, |
| 144 | + _In_ const sai_attribute_t *attr); |
| 145 | + |
| 146 | + |
| 147 | +sai_status_t vs_generic_get( |
| 148 | + _In_ sai_object_type_t object_type, |
| 149 | + _In_ sai_object_id_t object_id, |
| 150 | + _In_ uint32_t attr_count, |
| 151 | + _Out_ sai_attribute_t *attr_list); |
| 152 | + |
| 153 | +sai_status_t vs_generic_get( |
| 154 | + _In_ sai_object_type_t object_type, |
| 155 | + _In_ const sai_fdb_entry_t *fdb_entry, |
| 156 | + _In_ uint32_t attr_count, |
| 157 | + _Out_ sai_attribute_t *attr_list); |
| 158 | + |
| 159 | +sai_status_t vs_generic_get( |
| 160 | + _In_ sai_object_type_t object_type, |
| 161 | + _In_ const sai_neighbor_entry_t* neighbor_entry, |
| 162 | + _In_ uint32_t attr_count, |
| 163 | + _Out_ sai_attribute_t *attr_list); |
| 164 | + |
| 165 | +sai_status_t vs_generic_get( |
| 166 | + _In_ sai_object_type_t object_type, |
| 167 | + _In_ const sai_unicast_route_entry_t* unicast_route_entry, |
| 168 | + _In_ uint32_t attr_count, |
| 169 | + _Out_ sai_attribute_t *attr_list); |
| 170 | + |
| 171 | +sai_status_t vs_generic_get_vlan( |
| 172 | + _In_ sai_object_type_t object_type, |
| 173 | + _In_ sai_vlan_id_t vlan_id, |
| 174 | + _In_ uint32_t attr_count, |
| 175 | + _Out_ sai_attribute_t *attr_list); |
| 176 | + |
| 177 | +// notifications |
| 178 | + |
| 179 | +void handle_notification( |
| 180 | + _In_ const std::string ¬ification, |
| 181 | + _In_ const std::string &data, |
| 182 | + _In_ const std::vector<swss::FieldValueTuple> &values); |
| 183 | + |
| 184 | +#endif // __SAI_VS__ |
0 commit comments