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

Header files for UDF hash proposal #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions inc/sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ typedef enum _sai_api_t
SAI_API_SCHEDULER = 21, /**< sai_scheduler_api_t*/
SAI_API_SCHEDULER_GROUP = 22, /**< sai_scheduler_group_api_t*/
SAI_API_BUFFERS = 23, /**< sai_buffer_api_t */
SAI_API_HASH = 24, /**< sai_hash_api_t */
SAI_API_UDF = 25, /**< sai_udf_api_t */
} sai_api_t;

typedef enum _sai_log_level_t
Expand Down
190 changes: 190 additions & 0 deletions inc/saihash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* Copyright (c) 2014 Microsoft Open Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
* LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
* FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing
* permissions and limitations under the License.
*
* Microsoft would like to thank the following companies for their review and
* assistance with these files: Intel Corporation, Mellanox Technologies Ltd,
* Dell Products, L.P., Facebook, Inc
*
* Module Name:
*
* saihash.h
*
* Abstract:
*
* This module defines SAI Hash API
*
*/

#if !defined (__SAIHASH_H_)
#define __SAIHASH_H_

#include <saitypes.h>

/** \defgroup SAIHASH SAI - Hash specific API definitions.
*
* \{
*/

/**
* brief@ Attribute data for sai native hash fields
*/
typedef enum _sai_native_hash_field
{
/** Native hash field source IP.
* also refers to the outer source IP
* in case for encapsulated packets */
SAI_NATIVE_HASH_FIELD_SRC_IP = 0,

/** Native hash field destination IP
* also refers to the outer source IP
* in case for encapsulated packets */
SAI_NATIVE_HASH_FIELD_DST_IP = 1,

/** Native hash field inner source IP */
SAI_NATIVE_HASH_FIELD_INNER_SRC_IP = 2,

/** Native hash field inner destination IP */
SAI_NATIVE_HASH_FIELD_INNER_DST_IP = 3,

/** Native hash field vlan id */
SAI_NATIVE_HASH_FIELD_VLAN_ID = 4,

/** Native hash field IP protocol */
SAI_NATIVE_HASH_FIELD_IP_PROTOCOL = 5,

/** Native hash field ethernet type */
SAI_NATIVE_HASH_FIELD_ETHERTYPE = 6,

/** Native hash field L4 source port */
SAI_NATIVE_HASH_FIELD_L4_SRC_PORT = 7,

/** Native hash field L4 destination port */
SAI_NATIVE_HASH_FIELD_L4_DST_PORT = 8,

/** Native hash field source MAC */
SAI_NATIVE_HASH_FIELD_SRC_MAC = 9,

/** Native hash field destination MAC */
SAI_NATIVE_HASH_FIELD_DST_MAC = 10,

/** Native hash field source port */
SAI_NATIVE_HASH_FIELD_IN_PORT = 11,

} sai_native_hash_field_t;

/**
* @brief Hash attribute IDs
*/
typedef enum _sai_hash_attr_t
{
/** READ-ONLY */

/** READ-WRITE */

/** Hash native fields [sai_u32_list_t(sai_native_hash_field)] (CREATE_AND_SET) (default to an empty list) */
SAI_HASH_NATIVE_FIELD_LIST,

/** Hash UDF group [sai_object_list_t(sai_udf_group_t)] (CREATE_AND_SET) (default to an empty list) */
SAI_HASH_UDF_GROUP_LIST

} sai_hash_attr_t;

/**
* Routine Description:
* @brief Create hash
*
* Arguments:
* @param[out] hash_id - hash 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
*
*/
typedef sai_status_t(*sai_create_hash_fn)(
_Out_ sai_object_id_t* hash_id,
_In_ uint32_t attr_count,
_In_ sai_attribute_t *attr_list
);

/**
* Routine Description:
* @brief Remove hash
*
* Arguments:
* @param[in] hash_id - hash id
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
typedef sai_status_t(*sai_remove_hash_fn)(
_In_ sai_object_id_t hash_id
);

/**
* Routine Description:
* @brief Set hash attribute
*
* Arguments:
* @param[in] hash_id - hash id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
typedef sai_status_t (*sai_set_hash_attribute_fn)(
_In_ sai_object_id_t hash_id,
_In_ const sai_attribute_t *attr
);

/**
* Routine Description:
* @brief Get hash attribute value
*
* Arguments:
* @param[in] hash_id - hash id
* @param[in] attr_count - number of attributes
* @param[inout] attrs - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
typedef sai_status_t (*sai_get_hash_attribute_fn)(
_In_ sai_object_id_t hash_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list
);

/**
* @brief hash methods, retrieved via sai_api_query()
*/
typedef struct _sai_hash_api_t
{
sai_create_hash_fn create_hash;
sai_remove_hash_fn remove_hash;
sai_set_hash_attribute_fn set_hash_attribute;
sai_get_hash_attribute_fn get_hash_attribute;

} sai_hash_api_t;

/**
* \}
*/
#endif // __SAIHASH_H_
93 changes: 44 additions & 49 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,6 @@ typedef enum _sai_packet_action_t

} sai_packet_action_t;

/**
* Attribute data for SAI_SWITCH_ ATTR_LAG_HASH_FIELDS
* and SAI_SWITCH_ ATTR_ECMP_HASH_FIELDS
*/
typedef enum _sai_switch_hash_field_types_t
{
SAI_HASH_SRC_IP = 0,
SAI_HASH_DST_IP = 1,
SAI_HASH_VLAN_ID = 2,
SAI_HASH_IP_PROTOCOL = 3,
SAI_HASH_ETHERTYPE = 4,
SAI_HASH_L4_SOURCE_PORT = 5,
SAI_HASH_L4_DEST_PORT = 6,
SAI_HASH_SOURCE_MAC = 7,
SAI_HASH_DEST_MAC = 8,
SAI_HASH_IN_PORT = 9,
} sai_switch_hash_field_types_t;

/**
* Attribute data for SAI_SWITCH_ATTR_LAG_HASH_ALGO
* and SAI_SWITCH_ATTR_ECMP_HASH_ALGO
*/
typedef enum _sai_switch_hash_algo_t
{
SAI_HASH_XOR = 1,
SAI_HASH_CRC = 2,
SAI_HASH_RANDOM = 3,
} sai_switch_hash_algo_t;

/**
* @brief Attribute data for SAI_SWITCH_SWITCHING_MODE
*/
Expand All @@ -151,6 +122,23 @@ typedef enum _sai_switch_switching_mode_t

} sai_switch_switching_mode_t;

/**
* @brief Attribute data for SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_ALGORITHM
* and SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_ALGORITHM
*/
typedef enum _sai_hash_algorithm_t
{
/** CRC-based hash algorithm */
SAI_HASH_ALGORITHM_CRC = 1,

/** XOR-based hash algorithm */
SAI_HASH_ALGORITHM_XOR = 2,

/** Random-based hash algorithm */
SAI_HASH_RANDOM = 3,

} sai_hash_algorithm_t;

/**
* Attribute Id in sai_set_switch_attribute() and
* sai_get_switch_attribute() calls
Expand Down Expand Up @@ -263,6 +251,15 @@ typedef enum _sai_switch_attr_t
* may be modified */
SAI_SWITCH_ATTR_DEFAULT_TRAP_GROUP,

/** The hash object for packets going through ECMP [sai_object_id_t]
* The object id is read only, while the object attributes can be modified */
SAI_SWITCH_ATTR_ECMP_HASH,

/** The hash object for packets going through LAG [sai_object_id_t]
* The object id is read only, while the object attributes can be modified */
SAI_SWITCH_ATTR_LAG_HASH,


/** READ-WRITE */

/** Switching mode [sai_switch_switching_mode_t]
Expand Down Expand Up @@ -297,31 +294,29 @@ typedef enum _sai_switch_attr_t

SAI_SWITCH_ATTR_FDB_MULTICAST_MISS_ACTION,

/** Hash algorithm for all LAG in the switch[sai_switch_hash_algo_t]
* (default to SAI_HASH_CRC)
*/
SAI_SWITCH_ATTR_LAG_HASH_ALGO,
/** SAI ECMP default hash algorithm [sai_hash_algorithm] (default to SAI_HASH_ALGORITHM_CRC) */
SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_ALGORITHM,

/** Hash seed for all LAG in the switch[sai_switch_hash_seed_t]*/
SAI_SWITCH_ATTR_LAG_HASH_SEED,
/** SAI ECMP default hash seed [uint32_t] (default to 0) */
SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_SEED,

/** Hash fields for all LAG in the switch[sai_s32_list_t]
* (default all fields in sai_switch_hash_field_types_t are enabled)
*/
SAI_SWITCH_ATTR_LAG_HASH_FIELDS,
/** The hash object for IPv4 packets going through ECMP [sai_object_id_t] */
SAI_SWITCH_ATTR_ECMP_HASH_IPV4,

/** Hash algorithm for all ECMP in the switch[sai_switch_hash_algo_t]
* (default to SAI_HASH_CRC)
*/
SAI_SWITCH_ATTR_ECMP_HASH_ALGO,
/** The hash object for IPv4 in IPv4 packets going through ECMP [sai_object_id_t] */
SAI_SWITCH_ATTR_ECMP_HASH_IPV4_IN_IPV4,

/** Hash seed for all ECMP in the switch[sai_switch_hash_seed_t]*/
SAI_SWITCH_ATTR_ECMP_HASH_SEED,
/** SAI LAG default hash algorithm [sai_hash_algorithm] (default to SAI_HASH_ALGORITHM_CRC) */
SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_ALGORITHM,

/** Hash fields for all ECMP in the switch[sai_s32_list_t]
* (default all fields in sai_switch_hash_field_types_t are enabled)
*/
SAI_SWITCH_ATTR_ECMP_HASH_FIELDS,
/** SAI LAG default hash seed [uint32_t] (default to 0) */
SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_SEED,

/** The hash object for IPv4 packets going through LAG [sai_object_id_t] */
SAI_SWITCH_ATTR_LAG_HASH_IPV4,

/** The hash object for IPv4 in IPv4 packets going through LAG [sai_object_id_t] */
SAI_SWITCH_ATTR_LAG_HASH_IPV4_IN_IPV4,

/** ECMP max number of paths per group [uint32_t]
(default to 64) */
Expand Down
30 changes: 29 additions & 1 deletion inc/saitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,33 @@ typedef enum _sai_object_type_t {
SAI_OBJECT_TYPE_BUFFER_PROFILE = 23,
SAI_OBJECT_TYPE_PRIORITY_GROUP = 24,
SAI_OBJECT_TYPE_LAG_MEMBER = 25,
SAI_OBJECT_TYPE_MAX = 26
SAI_OBJECT_TYPE_HASH = 25,
SAI_OBJECT_TYPE_UDF = 26,
SAI_OBJECT_TYPE_UDF_MATCH = 27,
SAI_OBJECT_TYPE_UDF_GROUP = 28,
SAI_OBJECT_TYPE_MAX = 29
} sai_object_type_t;

typedef struct _sai_u8_list_t {
uint32_t count;
uint8_t *list;
} sai_u8_list_t;

typedef struct _sai_s8_list_t {
uint32_t count;
int8_t *list;
} sai_s8_list_t;

typedef struct _sai_u16_list_t {
uint32_t count;
uint16_t *list;
} sai_u16_list_t;

typedef struct _sai_s16_list_t {
uint32_t count;
int16_t *list;
} sai_s16_list_t;

typedef struct _sai_u32_list_t {
uint32_t count;
uint32_t *list;
Expand Down Expand Up @@ -445,6 +469,10 @@ typedef union {
sai_ip_address_t ipaddr;
sai_object_id_t oid;
sai_object_list_t objlist;
sai_u8_list_t u8list;
sai_s8_list_t s8list;
sai_u16_list_t u16list;
sai_s16_list_t s16list;
sai_u32_list_t u32list;
sai_s32_list_t s32list;
sai_u32_range_t u32range;
Expand Down
Loading