bhh_pkt.h (3331B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: bhh_pkt.h 8 * Purpose: BHH Packet Format definitions 9 * common to SDK and uKernel. 10 */ 11 12 #ifndef _SOC_SHARED_BHH_PKT_H_ 13 #define _SOC_SHARED_BHH_PKT_H_ 14 15 #ifdef BCM_UKERNEL 16 /* Build for uKernel not SDK */ 17 #include "sdk_typedefs.h" 18 #else 19 #include <sal/types.h> 20 #endif 21 22 #include <shared/pack.h> 23 #include <shared/bhh.h> 24 25 26 /******************************************* 27 * Pack/Unpack Macros 28 * 29 * Data is packed/unpacked in/from Network byte order 30 */ 31 #define SHR_BHH_ENCAP_PACK_U8(_buf, _var) _SHR_PACK_U8(_buf, _var) 32 #define SHR_BHH_ENCAP_PACK_U16(_buf, _var) _SHR_PACK_U16(_buf, _var) 33 #define SHR_BHH_ENCAP_PACK_U32(_buf, _var) _SHR_PACK_U32(_buf, _var) 34 #define SHR_BHH_ENCAP_UNPACK_U8(_buf, _var) _SHR_UNPACK_U8(_buf, _var) 35 #define SHR_BHH_ENCAP_UNPACK_U16(_buf, _var) _SHR_UNPACK_U16(_buf, _var) 36 #define SHR_BHH_ENCAP_UNPACK_U32(_buf, _var) _SHR_UNPACK_U32(_buf, _var) 37 38 #define SHR_BHH_ENCAP_UNPACK_ETYPE(_buf, _var) _SHR_UNPACK_U16(_buf, _var) 39 40 /****************************************** 41 * Network Packet Format definitions 42 * 43 * Note: LENGTH is specified in bytes unless noted otherwise 44 */ 45 46 /* BHH Control Packet lengths */ 47 #define SHR_BHH_HEADER_LENGTH 4 48 #define SHR_BHH_ACH_LENGTH 4 49 #define SHR_BHH_ACH_TYPE_LENGTH 2 50 #define SHR_BHH_LM_OFFSET_INSIDE_CCM_PDU 58 51 52 /* Associated Channel Header */ 53 #define SHR_BHH_ACH_FIRST_NIBBLE 0x1 54 #define SHR_BHH_ACH_VERSION 0x0 55 #define SHR_BHH_ACH_CHANNEL_TYPE 0x8902 56 #define SHR_BHH_ACH_CHANNEL_TYPE_1 0x7FFA 57 58 59 /* MPLS */ 60 #define SHR_BHH_MPLS_ROUTER_ALERT_LABEL 1 61 #define SHR_BHH_MPLS_GAL_LABEL 13 62 #define SHR_BHH_MPLS_PW_LABEL 0xFF 63 64 65 /* MPLS */ 66 #define SHR_BHH_MPLS_LABEL_LENGTH 4 67 #define SHR_BHH_MPLS_ROUTER_ALERT_LABEL 1 68 #define SHR_BHH_MPLS_GAL_LABEL 13 69 #define SHR_BHH_MPLS_LABEL_LABEL_LENGTH 3 /* Label field in MPLS */ 70 #define SHR_BHH_MPLS_LABEL_MASK 0xFFFFF000 71 72 #define SHR_BHH_MPLS_IS_BOS(_label) \ 73 (((_label)[2]) & 0x1) 74 #define SHR_BHH_MPLS_IS_GAL(_label) \ 75 (((_label)[0] == 0x00) && ((_label)[1] == 0x00) && \ 76 ((((_label)[2]) & 0xF0) == 0xD0)) 77 78 /* Ether Type */ 79 #define SHR_BHH_L2_ETYPE_MPLS_UCAST 0x8847 80 81 /* Ethernet Frame */ 82 #define SHR_BHH_ENET_UNTAGGED_MIN_PKT_SIZE 64 83 #define SHR_BHH_ENET_TAGGED_MIN_PKT_SIZE 68 84 #define SHR_BHH_L2_MAC_ADDR_LENGTH 6 85 #define SHR_BHH_L2_VLAN_HEADER_LENGTH 4 86 #define SHR_BHH_L2_ETYPE_LENGTH 2 87 88 /* BHH op-code */ 89 #define SHR_BHH_OPCODE_LEN 1 90 #define SHR_BHH_OPCODE_LM_PREFIX 42 91 #define SHR_BHH_OPCODE_DM_PREFIX 44 92 #define SHR_BHH_OPCODE_LM_MASK 0xFE 93 #define SHR_BHH_OPCODE_DM_MASK 0xFC 94 95 96 typedef struct shr_bhh_mpls_header_s { 97 #ifdef LE_HOST 98 uint32 ttl:8, 99 s:1, 100 exp:3, 101 label:20; 102 #else 103 uint32 label:20, 104 exp:3, 105 s:1, 106 ttl:8; 107 #endif 108 } shr_bhh_mpls_header_t; 109 110 #endif /* _SOC_SHARED_BHH_PKT_H_ */