Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame] | 1 | /*
|
| 2 | <:copyright-BRCM:2016:DUAL/GPL:standard
|
| 3 |
|
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom
|
| 5 | All Rights Reserved
|
| 6 |
|
| 7 | Unless you and Broadcom execute a separate written software license
|
| 8 | agreement governing use of this software, this software is licensed
|
| 9 | to you under the terms of the GNU General Public License version 2
|
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
|
| 11 | with the following added to such license:
|
| 12 |
|
| 13 | As a special exception, the copyright holders of this software give
|
| 14 | you permission to link this software with independent modules, and
|
| 15 | to copy and distribute the resulting executable under terms of your
|
| 16 | choice, provided that you also meet, for each linked independent
|
| 17 | module, the terms and conditions of the license of that module.
|
| 18 | An independent module is a module which is not derived from this
|
| 19 | software. The special exception does not apply to any modifications
|
| 20 | of the software.
|
| 21 |
|
| 22 | Not withstanding the above, under no circumstances may you combine
|
| 23 | this software in any way with any other Broadcom software provided
|
| 24 | under a license other than the GPL, without Broadcom's express prior
|
| 25 | written consent.
|
| 26 |
|
| 27 | :>
|
| 28 | */
|
| 29 |
|
| 30 | #ifndef OAM_DEFS_H_
|
| 31 | #define OAM_DEFS_H_
|
| 32 |
|
| 33 | #include "bcmolt_model_types.h"
|
| 34 |
|
| 35 | #define ETHERTYPE_SLOWPROTOCOLS 0x8809
|
| 36 | #define OAM_TIMEOUT_GRACE_PERIOD_US 100000
|
| 37 | #define HDE_ENABLE_OAM_WAIT_US 3e6 // 3 seconds
#define OAM_MAX_PACKET_SIZE 1518
|
| 38 | #define OAM_MAX_TLV_LENGTH 128
|
| 39 |
|
| 40 | /* Common OAMPDU Structure */
|
| 41 | typedef enum
|
| 42 | {
|
| 43 | SLOW_PROTOCOL_SUBTYPE_LACP = 0x01, /* Link Agregation Control Protocol */
|
| 44 | SLOW_PROTOCOL_SUBTYPE_LAMP = 0x02, /* Link Agregation Marker Protocol */
|
| 45 | SLOW_PROTOCOL_SUBTYPE_OAM = 0x03, /* OAM */
|
| 46 | SLOW_PROTOCOL_SUBTYPE_ORG_SPEC = 0x0A /* Organization Specific Subtype */
|
| 47 | } slow_protocol_subtype;
|
| 48 |
|
| 49 | /* Standard OAM Flags field. IEEE802.3-2008_section5, ch.57.4.2.1 */
|
| 50 | typedef enum
|
| 51 | {
|
| 52 | OAM_PDU_FLAG_LINK_FAULT = (1 << 0), /* 0x0001 */
|
| 53 | OAM_PDU_FLAG_DYING_GASP = (1 << 1), /* 0x0002 */
|
| 54 | OAM_PDU_FLAG_CRITICAL_EVENT = (1 << 2), /* 0x0004 */
|
| 55 | OAM_PDU_FLAG_LOCAL_EVAL = (1 << 3), /* 0x0008 */
|
| 56 | OAM_PDU_FLAG_LOCAL_STABLE = (1 << 4), /* 0x0010 */
|
| 57 | OAM_PDU_FLAG_REMOTE_EVAL = (1 << 5), /* 0x0020 */
|
| 58 | OAM_PDU_FLAG_REMOTE_STABLE = (1 << 6), /* 0x0040 */
|
| 59 | OAM_PDU_FLAG_SEND_ANY = (OAM_PDU_FLAG_LOCAL_STABLE | OAM_PDU_FLAG_REMOTE_STABLE)
|
| 60 | } oam_pdu_flag;
|
| 61 |
|
| 62 | /* Standard OAM Code field. IEEE802.3-2008_section5, ch.57.4.2.2 */
|
| 63 | typedef enum
|
| 64 | {
|
| 65 | OAM_PDU_CODE_INFO = 0x0,
|
| 66 | OAM_PDU_CODE_EVENTNOTIFICATION = 0x01,
|
| 67 | OAM_PDU_CODE_VARREQUEST = 0x02,
|
| 68 | OAM_PDU_CODE_VARRESPONSE = 0x03,
|
| 69 | OAM_PDU_CODE_LOOPBACK = 0x04,
|
| 70 | OAM_PDU_CODE_ORG_EXT = 0xfe
|
| 71 | } oam_pdu_code;
|
| 72 |
|
| 73 | /* IEEE Organization Unique Identifier */
|
| 74 | typedef struct
|
| 75 | {
|
| 76 | uint8_t byte[3];
|
| 77 | } ieee_oui;
|
| 78 |
|
| 79 | /* Branch types */
|
| 80 | typedef enum
|
| 81 | {
|
| 82 | OAM_VAR_BRANCH_TERMINATION = 0x00,
|
| 83 | OAM_VAR_BRANCH_ATTRIBUTE = 0x07,
|
| 84 | OAM_VAR_BRANCH_ACTION = 0x09,
|
| 85 | OAM_VAR_BRANCH_DPOE_OBJECT = 0xD6,
|
| 86 | OAM_VAR_BRANCH_DPOE_ATTRIBUTE = 0xD7,
|
| 87 | OAM_VAR_BRANCH_DPOE_PROG_CTR = 0xD8,
|
| 88 | OAM_VAR_BRANCH_DPOE_ACT = 0xD9
|
| 89 | } oam_var_branch;
|
| 90 |
|
| 91 | typedef enum
|
| 92 | {
|
| 93 | OAM_DPOE_OPCODE_RESERVED = 0,
|
| 94 | OAM_DPOE_OPCODE_GET_REQUEST = 1,
|
| 95 | OAM_DPOE_OPCODE_GET_RESPONSE = 2,
|
| 96 | OAM_DPOE_OPCODE_SET_REQUEST = 3,
|
| 97 | OAM_DPOE_OPCODE_SET_RESPONSE = 4,
|
| 98 | OAM_DPOE_OPCODE_IPMC_CTRL = 5,
|
| 99 | OAM_DPOE_OPCODE_MCAST_REG = 6,
|
| 100 | OAM_DPOE_OPCODE_MCAST_REG_RESP = 7,
|
| 101 | OAM_DPOE_OPCODE_KEY_EXCHANGE = 8,
|
| 102 | OAM_DPOE_OPCODE_FILE_TRANSFER = 9,
|
| 103 | OAM_DPOE_OPCODE_IPMC_CTRL_RESP = 0x0a /* DPoE 2.0 */
|
| 104 | } oam_dpoe_opcode;
|
| 105 |
|
| 106 | typedef enum
|
| 107 | {
|
| 108 | OAM_DPOE_ATTR_KEY_EXPIRY_TIME = 0x0401,
|
| 109 | OAM_DPOE_ATTR_ENCRYPT_MODE = 0x0402
|
| 110 | } oam_dpoe_attr;
|
| 111 |
|
| 112 | /* DPoE Key Exchange OAM TLV encryption mode */
|
| 113 | typedef enum
|
| 114 | {
|
| 115 | DPOE_ENCRYPT_MODE_NONE,
|
| 116 | DPOE_ENCRYPT_MODE_1DOWN,
|
| 117 | DPOE_ENCRYPT_MODE_10DOWN,
|
| 118 | DPOE_ENCRYPT_MODE_10BI
|
| 119 | } dpoe_encrypt_mode;
|
| 120 |
|
| 121 | /* generic OAM Variable format */
|
| 122 | typedef struct
|
| 123 | {
|
| 124 | oam_var_branch branch;
|
| 125 | uint16_t leaf;
|
| 126 | uint8_t width;
|
| 127 | uint8_t *value;
|
| 128 | } oam_var_generic;
|
| 129 |
|
| 130 | /** In the OAM protocol length 0 tlv is encoded as 0x80 (no error).
|
| 131 | * Length (1-127) are encoded with no change and 128 is encoded as 0.
|
| 132 | *
|
| 133 | * \param width TLV width field value
|
| 134 | * \return encoded value for the width field
|
| 135 | * \ref IEEE802.3-2008_section5, Ch. 57.6.2.1
|
| 136 | */
|
| 137 | static inline uint8_t oam_var_tlv_length_encode(uint8_t width)
|
| 138 | {
|
| 139 | if (width == 0)
|
| 140 | {
|
| 141 | return OAM_MAX_TLV_LENGTH; /* 0x00 equals 128 octets. */
|
| 142 | }
|
| 143 | else if (width == OAM_MAX_TLV_LENGTH)
|
| 144 | {
|
| 145 | return 0; /* 0x80 represents 'no error'. No 'Value' field. */
|
| 146 | }
|
| 147 | else
|
| 148 | {
|
| 149 | return width; /* represents the length of 'Value'. */
|
| 150 | }
|
| 151 | }
|
| 152 |
|
| 153 | #endif /* OAM_DEFS_H_ */
|