forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Virtual Switch skeleton (sonic-net#54)
- Loading branch information
Showing
35 changed files
with
6,098 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SUBDIRS = src | ||
|
||
ACLOCAL_AMFLAGS=-I m4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
#ifndef __SAI_VS__ | ||
#define __SAI_VS__ | ||
|
||
#include <mutex> | ||
#include <unordered_map> | ||
|
||
#include "stdint.h" | ||
#include "stdio.h" | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
#include "saiserialize.h" | ||
#include "saiattributelist.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
extern service_method_table_t g_services; | ||
|
||
extern uint64_t g_real_id; | ||
|
||
typedef std::unordered_map<std::string, std::string> AttrHash; | ||
typedef std::unordered_map<std::string, AttrHash> ObjectHash; | ||
|
||
// first key is serialized object ID (object id, vlan, route, neighbor, fdb) | ||
// value is hash containing attributes | ||
// second key is serialized attribute ID for given object | ||
// value is serialized attribute value | ||
extern ObjectHash g_objectHash; | ||
|
||
extern std::recursive_mutex g_recursive_mutex; | ||
|
||
extern const sai_acl_api_t vs_acl_api; | ||
extern const sai_buffer_api_t vs_buffer_api; | ||
extern const sai_fdb_api_t vs_fdb_api; | ||
extern const sai_hash_api_t vs_hash_api; | ||
extern const sai_hostif_api_t vs_host_interface_api; | ||
extern const sai_lag_api_t vs_lag_api; | ||
extern const sai_mirror_api_t vs_mirror_api; | ||
extern const sai_neighbor_api_t vs_neighbor_api; | ||
extern const sai_next_hop_api_t vs_next_hop_api; | ||
extern const sai_next_hop_group_api_t vs_next_hop_group_api; | ||
extern const sai_policer_api_t vs_policer_api; | ||
extern const sai_port_api_t vs_port_api; | ||
extern const sai_qos_map_api_t vs_qos_map_api; | ||
extern const sai_queue_api_t vs_queue_api; | ||
extern const sai_route_api_t vs_route_api; | ||
extern const sai_router_interface_api_t vs_router_interface_api; | ||
extern const sai_samplepacket_api_t vs_samplepacket_api; | ||
extern const sai_scheduler_api_t vs_scheduler_api; | ||
extern const sai_scheduler_group_api_t vs_scheduler_group_api; | ||
extern const sai_stp_api_t vs_stp_api; | ||
extern const sai_switch_api_t vs_switch_api; | ||
extern const sai_tunnel_api_t vs_tunnel_api; | ||
extern const sai_udf_api_t vs_udf_api; | ||
extern const sai_virtual_router_api_t vs_router_api; | ||
extern const sai_vlan_api_t vs_vlan_api; | ||
extern const sai_wred_api_t vs_wred_api; | ||
|
||
extern sai_switch_notification_t vs_switch_notifications; | ||
|
||
#define UNREFERENCED_PARAMETER(X) | ||
|
||
void translate_rid_to_vid( | ||
_In_ sai_object_type_t object_type, | ||
_In_ uint32_t attr_count, | ||
_In_ sai_attribute_t *attr_list); | ||
|
||
// separate methods are needed for vlan to not confuse with object_id | ||
|
||
sai_status_t vs_generic_create( | ||
_In_ sai_object_type_t object_type, | ||
_Out_ sai_object_id_t* object_id, | ||
_In_ uint32_t attr_count, | ||
_In_ const sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_create( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_fdb_entry_t *fdb_entry, | ||
_In_ uint32_t attr_count, | ||
_In_ const sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_create( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_neighbor_entry_t* neighbor_entry, | ||
_In_ uint32_t attr_count, | ||
_In_ const sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_create( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_unicast_route_entry_t* unicast_route_entry, | ||
_In_ uint32_t attr_count, | ||
_In_ const sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_create_vlan( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_vlan_id_t vlan_id); | ||
|
||
|
||
sai_status_t vs_generic_remove( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_object_id_t object_id); | ||
|
||
sai_status_t vs_generic_remove( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_fdb_entry_t* fdb_entry); | ||
|
||
sai_status_t vs_generic_remove( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_neighbor_entry_t* neighbor_entry); | ||
|
||
sai_status_t vs_generic_remove( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_unicast_route_entry_t* unicast_route_entry); | ||
|
||
sai_status_t vs_generic_remove_vlan( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_vlan_id_t vlan_id); | ||
|
||
|
||
sai_status_t vs_generic_set( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_object_id_t object_id, | ||
_In_ const sai_attribute_t *attr); | ||
|
||
sai_status_t vs_generic_set( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_fdb_entry_t *fdb_entry, | ||
_In_ const sai_attribute_t *attr); | ||
|
||
sai_status_t vs_generic_set( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_neighbor_entry_t* neighbor_entry, | ||
_In_ const sai_attribute_t *attr); | ||
|
||
sai_status_t vs_generic_set( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_unicast_route_entry_t* unicast_route_entry, | ||
_In_ const sai_attribute_t *attr); | ||
|
||
sai_status_t vs_generic_set_vlan( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_vlan_id_t vlan_id, | ||
_In_ const sai_attribute_t *attr); | ||
|
||
|
||
sai_status_t vs_generic_get( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_object_id_t object_id, | ||
_In_ uint32_t attr_count, | ||
_Out_ sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_get( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_fdb_entry_t *fdb_entry, | ||
_In_ uint32_t attr_count, | ||
_Out_ sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_get( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_neighbor_entry_t* neighbor_entry, | ||
_In_ uint32_t attr_count, | ||
_Out_ sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_get( | ||
_In_ sai_object_type_t object_type, | ||
_In_ const sai_unicast_route_entry_t* unicast_route_entry, | ||
_In_ uint32_t attr_count, | ||
_Out_ sai_attribute_t *attr_list); | ||
|
||
sai_status_t vs_generic_get_vlan( | ||
_In_ sai_object_type_t object_type, | ||
_In_ sai_vlan_id_t vlan_id, | ||
_In_ uint32_t attr_count, | ||
_Out_ sai_attribute_t *attr_list); | ||
|
||
// notifications | ||
|
||
void handle_notification( | ||
_In_ const std::string ¬ification, | ||
_In_ const std::string &data, | ||
_In_ const std::vector<swss::FieldValueTuple> &values); | ||
|
||
#endif // __SAI_VS__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Makefile.am -- Process this file with automake to produce Makefile.in | ||
|
||
AM_CPPFLAGS = | ||
AM_CPPFLAGS += -I/usr/include/sai -I/usr/include/swss -I$(top_srcdir)/common | ||
AM_CPPFLAGS += -I../inc | ||
|
||
if DEBUG | ||
DBGFLAGS = -ggdb -D_DEBUG_ | ||
else | ||
DBGFLAGS = -g | ||
endif | ||
|
||
lib_LTLIBRARIES = libsaivs.la | ||
|
||
libsaivs_la_SOURCES = sai_vs_acl.cpp \ | ||
sai_vs_buffer.cpp \ | ||
sai_vs_fdb.cpp \ | ||
sai_vs_hash.cpp \ | ||
sai_vs_hostintf.cpp \ | ||
sai_vs_interfacequery.cpp \ | ||
sai_vs_lag.cpp \ | ||
sai_vs_mirror.cpp \ | ||
sai_vs_neighbor.cpp \ | ||
sai_vs_nexthop.cpp \ | ||
sai_vs_nexthopgroup.cpp \ | ||
sai_vs_policer.cpp \ | ||
sai_vs_port.cpp \ | ||
sai_vs_qosmaps.cpp \ | ||
sai_vs_queue.cpp \ | ||
sai_vs_route.cpp \ | ||
sai_vs_router.cpp \ | ||
sai_vs_routerintf.cpp \ | ||
sai_vs_samplepacket.cpp \ | ||
sai_vs_scheduler.cpp \ | ||
sai_vs_schedulergroup.cpp \ | ||
sai_vs_stp.cpp \ | ||
sai_vs_switch.cpp \ | ||
sai_vs_tunnel.cpp \ | ||
sai_vs_udf.cpp \ | ||
sai_vs_vlan.cpp \ | ||
sai_vs_wred.cpp \ | ||
sai_vs_generic_create.cpp \ | ||
sai_vs_generic_remove.cpp \ | ||
sai_vs_generic_set.cpp \ | ||
sai_vs_generic_get.cpp \ | ||
../../common/saiserialize.cpp \ | ||
../../common/saiattributelist.cpp | ||
|
||
|
||
libsaivs_la_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON) | ||
|
||
libsaivs_la_LIBADD = -lhiredis -lswsscommon |
Oops, something went wrong.