blob: 276d5ebc629dd79645e8b118b4a5450d9edc8242 [file] [log] [blame]
/*
<:copyright-BRCM:2016:DUAL/GPL:standard
Broadcom Proprietary and Confidential.(c) 2016 Broadcom
All Rights Reserved
Unless you and Broadcom execute a separate written software license
agreement governing use of this software, this software is licensed
to you under the terms of the GNU General Public License version 2
(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
with the following added to such license:
As a special exception, the copyright holders of this software give
you permission to link this software with independent modules, and
to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent
module, the terms and conditions of the license of that module.
An independent module is a module which is not derived from this
software. The special exception does not apply to any modifications
of the software.
Not withstanding the above, under no circumstances may you combine
this software in any way with any other Broadcom software provided
under a license other than the GPL, without Broadcom's express prior
written consent.
:>
*/
#ifndef OAM_DEFS_H_
#define OAM_DEFS_H_
#include "bcmolt_model_types.h"
#define ETHERTYPE_SLOWPROTOCOLS 0x8809
#define OAM_TIMEOUT_GRACE_PERIOD_US 100000
#define HDE_ENABLE_OAM_WAIT_US 3e6 // 3 seconds #define OAM_MAX_PACKET_SIZE 1518
#define OAM_MAX_TLV_LENGTH 128
/* Common OAMPDU Structure */
typedef enum
{
SLOW_PROTOCOL_SUBTYPE_LACP = 0x01, /* Link Agregation Control Protocol */
SLOW_PROTOCOL_SUBTYPE_LAMP = 0x02, /* Link Agregation Marker Protocol */
SLOW_PROTOCOL_SUBTYPE_OAM = 0x03, /* OAM */
SLOW_PROTOCOL_SUBTYPE_ORG_SPEC = 0x0A /* Organization Specific Subtype */
} slow_protocol_subtype;
/* Standard OAM Flags field. IEEE802.3-2008_section5, ch.57.4.2.1 */
typedef enum
{
OAM_PDU_FLAG_LINK_FAULT = (1 << 0), /* 0x0001 */
OAM_PDU_FLAG_DYING_GASP = (1 << 1), /* 0x0002 */
OAM_PDU_FLAG_CRITICAL_EVENT = (1 << 2), /* 0x0004 */
OAM_PDU_FLAG_LOCAL_EVAL = (1 << 3), /* 0x0008 */
OAM_PDU_FLAG_LOCAL_STABLE = (1 << 4), /* 0x0010 */
OAM_PDU_FLAG_REMOTE_EVAL = (1 << 5), /* 0x0020 */
OAM_PDU_FLAG_REMOTE_STABLE = (1 << 6), /* 0x0040 */
OAM_PDU_FLAG_SEND_ANY = (OAM_PDU_FLAG_LOCAL_STABLE | OAM_PDU_FLAG_REMOTE_STABLE)
} oam_pdu_flag;
/* Standard OAM Code field. IEEE802.3-2008_section5, ch.57.4.2.2 */
typedef enum
{
OAM_PDU_CODE_INFO = 0x0,
OAM_PDU_CODE_EVENTNOTIFICATION = 0x01,
OAM_PDU_CODE_VARREQUEST = 0x02,
OAM_PDU_CODE_VARRESPONSE = 0x03,
OAM_PDU_CODE_LOOPBACK = 0x04,
OAM_PDU_CODE_ORG_EXT = 0xfe
} oam_pdu_code;
/* IEEE Organization Unique Identifier */
typedef struct
{
uint8_t byte[3];
} ieee_oui;
/* Branch types */
typedef enum
{
OAM_VAR_BRANCH_TERMINATION = 0x00,
OAM_VAR_BRANCH_ATTRIBUTE = 0x07,
OAM_VAR_BRANCH_ACTION = 0x09,
OAM_VAR_BRANCH_DPOE_OBJECT = 0xD6,
OAM_VAR_BRANCH_DPOE_ATTRIBUTE = 0xD7,
OAM_VAR_BRANCH_DPOE_PROG_CTR = 0xD8,
OAM_VAR_BRANCH_DPOE_ACT = 0xD9
} oam_var_branch;
typedef enum
{
OAM_DPOE_OPCODE_RESERVED = 0,
OAM_DPOE_OPCODE_GET_REQUEST = 1,
OAM_DPOE_OPCODE_GET_RESPONSE = 2,
OAM_DPOE_OPCODE_SET_REQUEST = 3,
OAM_DPOE_OPCODE_SET_RESPONSE = 4,
OAM_DPOE_OPCODE_IPMC_CTRL = 5,
OAM_DPOE_OPCODE_MCAST_REG = 6,
OAM_DPOE_OPCODE_MCAST_REG_RESP = 7,
OAM_DPOE_OPCODE_KEY_EXCHANGE = 8,
OAM_DPOE_OPCODE_FILE_TRANSFER = 9,
OAM_DPOE_OPCODE_IPMC_CTRL_RESP = 0x0a /* DPoE 2.0 */
} oam_dpoe_opcode;
typedef enum
{
OAM_DPOE_ATTR_KEY_EXPIRY_TIME = 0x0401,
OAM_DPOE_ATTR_ENCRYPT_MODE = 0x0402
} oam_dpoe_attr;
/* DPoE Key Exchange OAM TLV encryption mode */
typedef enum
{
DPOE_ENCRYPT_MODE_NONE,
DPOE_ENCRYPT_MODE_1DOWN,
DPOE_ENCRYPT_MODE_10DOWN,
DPOE_ENCRYPT_MODE_10BI
} dpoe_encrypt_mode;
/* generic OAM Variable format */
typedef struct
{
oam_var_branch branch;
uint16_t leaf;
uint8_t width;
uint8_t *value;
} oam_var_generic;
/** In the OAM protocol length 0 tlv is encoded as 0x80 (no error).
* Length (1-127) are encoded with no change and 128 is encoded as 0.
*
* \param width TLV width field value
* \return encoded value for the width field
* \ref IEEE802.3-2008_section5, Ch. 57.6.2.1
*/
static inline uint8_t oam_var_tlv_length_encode(uint8_t width)
{
if (width == 0)
{
return OAM_MAX_TLV_LENGTH; /* 0x00 equals 128 octets. */
}
else if (width == OAM_MAX_TLV_LENGTH)
{
return 0; /* 0x80 represents 'no error'. No 'Value' field. */
}
else
{
return width; /* represents the length of 'Value'. */
}
}
#endif /* OAM_DEFS_H_ */