Skip to content

Commit

Permalink
update to use SAI 1.2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lguohan committed Jan 17, 2018
1 parent 36752e1 commit eb8be5a
Show file tree
Hide file tree
Showing 53 changed files with 491 additions and 420 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
path = SAI
url = https://github.com/opencomputeproject/SAI.git
ignore = dirty
branch = v1.2
2 changes: 1 addition & 1 deletion SAI
Submodule SAI updated 100 files
2 changes: 1 addition & 1 deletion lib/inc/sai_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern volatile bool g_useTempView;
extern volatile bool g_asicInitViewMode;
extern volatile bool g_logrotate;

extern service_method_table_t g_services;
extern sai_service_method_table_t g_services;
extern std::shared_ptr<swss::ProducerTable> g_asicState;
extern std::shared_ptr<swss::ConsumerTable> g_redisGetConsumer;
extern std::shared_ptr<swss::NotificationConsumer> g_redisNotifications;
Expand Down
24 changes: 12 additions & 12 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ typedef enum _sai_redis_switch_attr_t
* @param[in] attr_count List of attr_count. Caller passes the number
* of attribute for each object to create.
* @param[in] attr_list List of attributes for every object.
* @param[in] type Bulk operation type.
* @param[in] mode Bulk operation error handling mode
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
Expand All @@ -147,15 +147,15 @@ sai_status_t sai_bulk_create_route_entry(
_In_ const sai_route_entry_t *route_entry,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t *const *attr_list,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

/**
* @brief Bulk remove route entry
*
* @param[in] object_count Number of objects to remove
* @param[in] route_entry List of objects to remove
* @param[in] type Bulk operation type.
* @param[in] mode Bulk operation error handling mode
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
Expand All @@ -167,7 +167,7 @@ sai_status_t sai_bulk_create_route_entry(
sai_status_t sai_bulk_remove_route_entry(
_In_ uint32_t object_count,
_In_ const sai_route_entry_t *route_entry,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

/**
Expand All @@ -176,7 +176,7 @@ sai_status_t sai_bulk_remove_route_entry(
* @param[in] object_count Number of objects to set attribute
* @param[in] route_entry List of objects to set attribute
* @param[in] attr_list List of attributes to set on objects, one attribute per object
* @param[in] type Bulk operation type.
* @param[in] mode Bulk operation error handling mode
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
Expand All @@ -189,7 +189,7 @@ sai_status_t sai_bulk_set_route_entry_attribute(
_In_ uint32_t object_count,
_In_ const sai_route_entry_t *route_entry,
_In_ const sai_attribute_t *attr_list,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

/**
Expand All @@ -200,7 +200,7 @@ sai_status_t sai_bulk_set_route_entry_attribute(
* @param[in] attr_count List of attr_count. Caller passes the number
* of attribute for each object to get
* @param[inout] attr_list List of attributes to set on objects, one attribute per object
* @param[in] type Bulk operation type
* @param[in] mode Bulk operation error handling mode
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
Expand All @@ -214,35 +214,35 @@ sai_status_t sai_bulk_get_route_entry_attribute(
_In_ const sai_route_entry_t *route_entry,
_In_ const uint32_t *attr_count,
_Inout_ sai_attribute_t **attr_list,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

sai_status_t sai_bulk_create_next_hop_group_members(
_In_ sai_object_id_t switch_id,
_In_ uint32_t object_count,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t *const *attrs,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_object_id_t *object_id,
_Out_ sai_status_t *object_statuses);

sai_status_t sai_bulk_remove_next_hop_group_members(
_In_ uint32_t object_count,
_In_ const sai_object_id_t *object_id,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

sai_status_t sai_bulk_create_fdb_entry(
_In_ uint32_t object_count,
_In_ const sai_fdb_entry_t *fdb_entry,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t *const *attr_list,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

sai_status_t sai_bulk_remove_fdb_entry(
_In_ uint32_t object_count,
_In_ const sai_fdb_entry_t *fdb_entry,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);
#endif // __SAIREDIS__
57 changes: 57 additions & 0 deletions lib/src/sai_redis_bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,67 @@
#include "sai_redis.h"

sai_status_t redis_get_bridge_stats(
_In_ sai_object_id_t bridge_id,
_In_ uint32_t number_of_counters,
_In_ const sai_bridge_stat_t *counter_ids,
_Out_ uint64_t *counters)
{
MUTEX();

SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t redis_clear_bridge_stats(
_In_ sai_object_id_t bridge_id,
_In_ uint32_t number_of_counters,
_In_ const sai_bridge_stat_t *counter_ids)
{
MUTEX();

SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t redis_get_bridge_port_stats(
_In_ sai_object_id_t bridge_port_id,
_In_ uint32_t number_of_counters,
_In_ const sai_bridge_port_stat_t *counter_ids,
_Out_ uint64_t *counters)
{
MUTEX();

SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t redis_clear_bridge_port_stats(
_In_ sai_object_id_t bridge_port_id,
_In_ uint32_t number_of_counters,
_In_ const sai_bridge_port_stat_t *counter_ids)
{
MUTEX();

SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

REDIS_GENERIC_QUAD(BRIDGE,bridge);
REDIS_GENERIC_QUAD(BRIDGE_PORT,bridge_port);

const sai_bridge_api_t redis_bridge_api =
{
REDIS_GENERIC_QUAD_API(bridge)

redis_get_bridge_stats,
redis_clear_bridge_stats,

REDIS_GENERIC_QUAD_API(bridge_port)

redis_get_bridge_port_stats,
redis_clear_bridge_port_stats,
};
16 changes: 8 additions & 8 deletions lib/src/sai_redis_fdb.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"

sai_status_t redis_flush_fdb_entries(
_In_ sai_object_id_t switch_id,
Expand Down Expand Up @@ -44,7 +44,7 @@ sai_status_t sai_bulk_create_fdb_entry(
_In_ const sai_fdb_entry_t *fdb_entry,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t *const *attr_list,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
std::lock_guard<std::mutex> lock(g_apimutex);
Expand Down Expand Up @@ -79,16 +79,16 @@ sai_status_t sai_bulk_create_fdb_entry(
return SAI_STATUS_INVALID_PARAMETER;
}

switch (type)
switch (mode)
{
case SAI_BULK_OP_TYPE_STOP_ON_ERROR:
case SAI_BULK_OP_TYPE_INGORE_ERROR:
case SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR:
case SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR:
// ok
break;

default:

SWSS_LOG_ERROR("invalid bulk operation type %d", type);
SWSS_LOG_ERROR("invalid bulk operation mode %d", mode);

return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ sai_status_t sai_bulk_create_fdb_entry(
idx,
serialized_object_ids[idx].c_str());

if (type == SAI_BULK_OP_TYPE_STOP_ON_ERROR)
if (mode == SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR)
{
SWSS_LOG_NOTICE("stop on error since previous operation failed");
break;
Expand All @@ -156,7 +156,7 @@ sai_status_t sai_bulk_create_fdb_entry(
sai_status_t sai_bulk_remove_fdb_entry(
_In_ uint32_t object_count,
_In_ const sai_fdb_entry_t *fdb_entry,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
std::lock_guard<std::mutex> lock(g_apimutex);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_create.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"
#include "meta/saiattributelist.h"

bool switch_ids[MAX_SWITCHES] = {};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_get.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"
#include "meta/saiattributelist.h"

sai_status_t internal_redis_get_process(
Expand Down
18 changes: 17 additions & 1 deletion lib/src/sai_redis_generic_get_stats.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"

sai_status_t internal_redis_get_stats_process(
_In_ sai_object_type_t object_type,
Expand Down Expand Up @@ -54,6 +54,13 @@ struct stat_traits<sai_port_stat_t>
static constexpr serialize_stat serialize_stat_fn = sai_serialize_port_stat;
};

template <>
struct stat_traits<sai_port_pool_stat_t>
{
typedef std::string (*serialize_stat)(sai_port_pool_stat_t);
static constexpr serialize_stat serialize_stat_fn = sai_serialize_port_pool_stat;
};

template <>
struct stat_traits<sai_queue_stat_t>
{
Expand All @@ -68,6 +75,13 @@ struct stat_traits<sai_ingress_priority_group_stat_t>
static constexpr serialize_stat serialize_stat_fn = sai_serialize_ingress_priority_group_stat;
};

template <>
struct stat_traits<sai_tunnel_stat_t>
{
typedef std::string (*serialize_stat)(sai_tunnel_stat_t);
static constexpr serialize_stat serialize_stat_fn = sai_serialize_tunnel_stat;
};


template <class T>
std::vector<swss::FieldValueTuple> serialize_counter_id_list(
Expand Down Expand Up @@ -213,5 +227,7 @@ sai_status_t redis_generic_get_stats(
_Out_ uint64_t *counter_list); \

DECLARE_REDIS_GENERIC_GET_STATS(port);
DECLARE_REDIS_GENERIC_GET_STATS(port_pool);
DECLARE_REDIS_GENERIC_GET_STATS(queue);
DECLARE_REDIS_GENERIC_GET_STATS(ingress_priority_group);
DECLARE_REDIS_GENERIC_GET_STATS(tunnel);
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_remove.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"
#include "meta/saiattributelist.h"

sai_status_t internal_redis_generic_remove(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_set.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"
#include "meta/saiattributelist.h"

sai_status_t internal_redis_generic_set(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sai_redis_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

std::mutex g_apimutex;

service_method_table_t g_services;
sai_service_method_table_t g_services;
bool g_apiInitialized = false;
volatile bool g_run = false;

Expand Down Expand Up @@ -95,7 +95,7 @@ void ntf_thread()

sai_status_t sai_api_initialize(
_In_ uint64_t flags,
_In_ const service_method_table_t* services)
_In_ const sai_service_method_table_t* services)
{
std::lock_guard<std::mutex> lock(g_apimutex);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/sai_redis_lag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sai_status_t redis_bulk_object_create_lag(
_In_ uint32_t object_count,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t **attrs,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_object_id_t *object_id,
_Out_ sai_status_t *object_statuses)
{
Expand All @@ -19,7 +19,7 @@ sai_status_t redis_bulk_object_create_lag(
sai_status_t redis_bulk_object_remove_lag(
_In_ uint32_t object_count,
_In_ const sai_object_id_t *object_id,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sai_redis_nexthopgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sai_status_t sai_bulk_create_next_hop_group_members(
_In_ uint32_t object_count,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t *const *attrs,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_object_id_t *object_id,
_Out_ sai_status_t *object_statuses)
{
Expand All @@ -20,7 +20,7 @@ sai_status_t sai_bulk_create_next_hop_group_members(
sai_status_t sai_bulk_remove_next_hop_group_members(
_In_ uint32_t object_count,
_In_ const sai_object_id_t *object_id,
_In_ sai_bulk_op_type_t type,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_notifications.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sai_redis.h"
#include "meta/saiserialize.h"
#include "meta/sai_serialize.h"
#include "meta/saiattributelist.h"

/*
Expand Down
Loading

0 comments on commit eb8be5a

Please sign in to comment.