Skip to content

Commit

Permalink
Adding tunnel support (sonic-net#33)
Browse files Browse the repository at this point in the history
  - added references to sai_tunnel_api in syncd.h, syncd_init.cpp, and
    sai_redis.h
  - added redis mapping of sai_tunnel_api by creating sai_redis_tunnel.cpp
    and adding reference to sai_redis_interfacequery.cpp
  - added sai_redis_tunnel.cpp to Makefile for compiling
  • Loading branch information
scsmncao authored and stcheng committed Jul 14, 2016
1 parent fc64008 commit de39dd8
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/inc/sai_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ extern const sai_scheduler_api_t redis_scheduler_api;
extern const sai_scheduler_group_api_t redis_scheduler_group_api;
extern const sai_stp_api_t redis_stp_api;
extern const sai_switch_api_t redis_switch_api;
extern const sai_tunnel_api_t redis_tunnel_api;
extern const sai_udf_api_t redis_udf_api;
extern const sai_virtual_router_api_t redis_router_api;
extern const sai_vlan_api_t redis_vlan_api;
Expand Down
1 change: 1 addition & 0 deletions lib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ libsairedis_la_SOURCES = sai_redis_acl.cpp \
sai_redis_schedulergroup.cpp \
sai_redis_stp.cpp \
sai_redis_switch.cpp \
sai_redis_tunnel.cpp \
sai_redis_udf.cpp \
sai_redis_vlan.cpp \
sai_redis_wred.cpp \
Expand Down
4 changes: 4 additions & 0 deletions lib/src/sai_redis_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ sai_status_t sai_api_query(
*(const sai_lag_api_t**)api_method_table = &redis_lag_api;
return SAI_STATUS_SUCCESS;

case SAI_API_TUNNEL:
*(const sai_tunnel_api_t**)api_method_table = &redis_tunnel_api;
return SAI_STATUS_SUCCESS;

default:
SWSS_LOG_ERROR("Invalid API type %d", sai_api_id);
return SAI_STATUS_INVALID_PARAMETER;
Expand Down
344 changes: 344 additions & 0 deletions lib/src/sai_redis_tunnel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,344 @@
#include "sai_redis.h"

/**
* Routine Description:
* @brief Create tunnel map
*
* Arguments:
* @param[out] tunnel_map_id - tunnel map id
* @param[in] attr_count - number of attributes
* @param[in] attr_list - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_create_tunnel_map(
_Out_ sai_object_id_t* tunnel_map_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_create(
SAI_OBJECT_TYPE_TUNNEL_MAP,
tunnel_map_id,
attr_count,
attr_list);

return status;
}

/**
* Routine Description:
* @brief Remove tunnel map
*
* Arguments:
* @param[out] tunnel_map_id - tunnel map id
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_remove_tunnel_map(
_In_ sai_object_id_t tunnel_map_id)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_remove(
SAI_OBJECT_TYPE_TUNNEL_MAP,
tunnel_map_id);

return status;
}

/**
* Routine Description:
* @brief Set tunnel map attribute Value
*
* Arguments:
* @param[in] tunnel_map_id - tunnel map id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_set_tunnel_map_attribute(
_In_ sai_object_id_t tunnel_map_id,
_In_ const sai_attribute_t *attr)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_set(
SAI_OBJECT_TYPE_TUNNEL_MAP,
tunnel_map_id,
attr);

return status;
}

/**
* Routine Description:
* @brief Get tunnel map attribute Value
*
* Arguments:
* @param[in] tunnel_map_id - tunnel map id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_get_tunnel_map_attribute(
_In_ sai_object_id_t tunnel_map_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_get(
SAI_OBJECT_TYPE_TUNNEL_MAP,
tunnel_map_id,
attr_count,
attr_list);

return status;
}

/**
* Routine Description:
* @brief Create tunnel
*
* Arguments:
* @param[out] tunnel_id - tunnel id
* @param[in] attr_count - number of attributes
* @param[in] attr_list - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_create_tunnel(
_Out_ sai_object_id_t* tunnel_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_create(
SAI_OBJECT_TYPE_TUNNEL,
tunnel_id,
attr_count,
attr_list);

return status;
}

/**
* Routine Description:
* @brief Remove tunnel
*
* Arguments:
* @param[out] tunnel_id - tunnel map
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_remove_tunnel(
_In_ sai_object_id_t tunnel_id)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_remove(
SAI_OBJECT_TYPE_TUNNEL,
tunnel_id);

return status;
}

/**
* Routine Description:
* @brief Set tunnel attribute Value
*
* Arguments:
* @param[in] tunnel_id - tunnel id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_set_tunnel_attribute(
_In_ sai_object_id_t tunnel_id,
_In_ const sai_attribute_t *attr)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_set(
SAI_OBJECT_TYPE_TUNNEL,
tunnel_id,
attr);

return status;
}

/**
* Routine Description:
* @brief Get tunnel attribute Value
*
* Arguments:
* @param[in] tunnel_id - tunnel id
* @param[in] attr_count - number of attributes
* @param[in] attr_list - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_get_tunnel_attribute(
_In_ sai_object_id_t tunnel_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_get(
SAI_OBJECT_TYPE_TUNNEL,
tunnel_id,
attr_count,
attr_list);

return status;
}

/**
* Routine Description:
* @brief Create tunnel term table
*
* Arguments:
* @param[out] tunnel_term_table_entry_id - tunnel term table entry id
* @param[in] attr_count - number of attributes
* @param[in] attr_list - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_create_tunnel_term_table_entry (
_Out_ sai_object_id_t* tunnel_term_table_entry_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_create(
SAI_OBJECT_TYPE_TUNNEL_TABLE_ENTRY,
tunnel_term_table_entry_id,
attr_count,
attr_list);

return status;
}

/**
* Routine Description:
* @brief Remove tunnel term table
*
* Arguments:
* @param[out] tunnel_term_table_entry_id - tunnel term table entry id
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*
*/
sai_status_t redis_remove_tunnel_term_table_entry (
_In_ sai_object_id_t tunnel_term_table_entry_id)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_remove(
SAI_OBJECT_TYPE_TUNNEL_TABLE_ENTRY,
tunnel_term_table_entry_id);

return status;
}

/**
* Routine Description:
* @brief Set tunnel term table attribute Value
*
* Arguments:
* @param[in] tunnel_term_table_entry_id, - tunnel term table id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_set_tunnel_term_table_entry_attribute(
_In_ sai_object_id_t tunnel_term_table_entry_id,
_In_ const sai_attribute_t *attr)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_set(
SAI_OBJECT_TYPE_TUNNEL_TABLE_ENTRY,
tunnel_term_table_entry_id,
attr);

return status;
}

/**
* Routine Description:
* @brief Get tunnel term table attribute Value
*
* Arguments:
* @param[in] tunnel_term_table_entry_id, - tunnel term table id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_get_tunnel_term_table_entry_attribute(
_In_ sai_object_id_t tunnel_term_table_entry_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

sai_status_t status = redis_generic_get(
SAI_OBJECT_TYPE_TUNNEL_TABLE_ENTRY,
tunnel_term_table_entry_id,
attr_count,
attr_list);

return status;
}

/**
* @brief tunnel table methods, retrieved via sai_api_query()
*/
const sai_tunnel_api_t redis_tunnel_api = {
redis_create_tunnel_map,
redis_remove_tunnel_map,
redis_set_tunnel_map_attribute,
redis_get_tunnel_map_attribute,
redis_create_tunnel,
redis_remove_tunnel,
redis_set_tunnel_attribute,
redis_get_tunnel_attribute,
redis_create_tunnel_term_table_entry,
redis_remove_tunnel_term_table_entry,
redis_set_tunnel_term_table_entry_attribute,
redis_get_tunnel_term_table_entry_attribute,
};
1 change: 1 addition & 0 deletions syncd/syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ extern sai_scheduler_api_t *sai_scheduler_api;
extern sai_scheduler_group_api_t *sai_scheduler_group_api;
extern sai_stp_api_t *sai_stp_api;
extern sai_switch_api_t *sai_switch_api;
extern sai_tunnel_api_t *sai_tunnel_api;
extern sai_udf_api_t *sai_udf_api;
extern sai_virtual_router_api_t *sai_router_api;
extern sai_vlan_api_t *sai_vlan_api;
Expand Down
Loading

0 comments on commit de39dd8

Please sign in to comment.