disc_int.h (10334B)
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: disc_int.h 8 * Purpose: Internal header file for discovery 9 */ 10 11 #ifndef _DISC_INT_H_ 12 #define _DISC_INT_H_ 13 14 #include <shared/util.h> 15 #include <bcm/types.h> 16 17 #define PACK_SHORT(buf, val) _SHR_PACK_SHORT(buf, val) 18 #define PACK_LONG(buf, val) _SHR_PACK_LONG(buf, val) 19 #define UNPACK_SHORT(buf, val) _SHR_UNPACK_SHORT(buf, val) 20 #define UNPACK_LONG(buf, val) _SHR_UNPACK_LONG(buf, val) 21 22 #define PACK_U32_INCR(buf, val) do { \ 23 _SHR_PACK_LONG(buf, val); (buf) += sizeof(uint32); \ 24 } while (0) 25 26 #define UNPACK_U32_INCR(buf, val) do { \ 27 _SHR_UNPACK_LONG(buf, val); (buf) += sizeof(uint32); \ 28 } while (0) 29 30 31 /********************************************************************* 32 * 33 * PACKET FORMAT DESCRIPTIONS 34 * 35 * Number indicated on each packet format are in bytes unit. 36 * 37 * Discovery Packet Format 38 * 39 * |<---------- Discovery packet --------->| 40 * +----------------+---------------------------------------+ 41 * | <cputrans-hdr> | <disc-pkt-hdr> | <disc-pkt-entry> * n | 42 * +----------------+---------------------------------------+ 43 * <n = ENTRY_COUNT> 44 * 45 * 46 * <disc-pkt-hdr> - Discovery packet header for all packet types, 47 * probe, routing, and config packets. 48 * +-------------------------------------------------------------+ 49 * | DISC_VER | RSVD_TTL | PKT_TYPE | ENTRY_COUNT | SRC_DSEQ_NUM | 50 * +-------------------------------------------------------------+ 51 * 1 1 1 1 4 52 * 53 * 54 * <disc-pkt-entry> - There are 3 types of discovery packets, 55 * Probe <probe-pkt-entry> 56 * Routing <route-pkt-entry> 57 * Config <cfg-pkt-entry> 58 * 59 * The number of entries in the discovery packet is specified 60 * in the ENTRY_COUNT field. 61 * 62 * See below for more details on each of the discovery packet types. 63 * 64 * 65 ***************** 66 * 67 * Probe Packet Entry 68 * 69 * <probe-pkt-entry> 70 * +----------------------------------------+ 71 * | KEY | MAC | DSEQ_NUM | RX_IDX | TX_IDX | 72 * +----------------------------------------+ 73 * 6 6 4 1 1 74 * 75 * 76 * The source dseq_num in the header is ignored in probe packets. 77 * 78 * RX_IDX indicates the port on which the packet was 79 * originally received by the CPU for this entry. It is ignored 80 * for the first entry. 81 * 82 * TX_IDX indicates the stack port on which CPU KEY transmitted this pkt. 83 * 84 **************** 85 * 86 * Routing Packet Entry 87 * 88 * The base format is the same as a probe packet (discovery header 89 * is the same). 90 * 91 * <route-pkt-entry> cont-> 92 * +--------------------------------------------------------- 93 * | KEY | MAC | DSEQ_NUM | FLAGS | SLOT_ID | MASTER_PRI | .. 94 * +--------------------------------------------------------- 95 * 6 6 4 4 4 4 96 * 97 * cont-> cont-> 98 * --------------------------------------------------------- 99 * .. | APP_DATA | NUM_UNITS | DEST_UNIT | DEST_PORT | .. 100 * --------------------------------------------------------- 101 * 8 4 4 4 102 * 103 * cont-> 104 * ---------------------------------------------------+ 105 * .. | STK_COUNT | <mod-entry> * m | <stk-entry> * s | 106 * ---------------------------------------------------+ 107 * 4 <m = NUM_UNITS> <s = STK_COUNT> 108 * 109 * 110 * Unless indicated, the following formats applies to all discovery 111 * versions. 112 * 113 * <mod-entry> - Contains mod ID information. The number of 114 * entries is specified in the NUM_UNITS 115 * field. The format for each entry is as follows, 116 * 117 * +------------------------+ 118 * | MODID_REQ | PREF_MODID | 119 * +------------------------+ 120 * 4 4 121 * 122 * <stk-entry> - Contains stack port information. The number 123 * of entries is specified in the STK_COUNT 124 * field. The format for each entry is as follows, 125 * 126 * discovery-v0 127 * +---------------------------------------------+ 128 * | SP_FLAG | TX_KEY | TX_IDX | RX_KEY | RX_IDX | 129 * +---------------------------------------------+ 130 * 4 6 4 6 4 131 * 132 * discovery-v1 133 * +---------------------------------------------------------------+ 134 * | SP_FLAG | TX_KEY | TX_IDX | RX_KEY | RX_IDX | WEIGHT | BFLAGS | 135 * +---------------------------------------------------------------+ 136 * 4 6 4 6 4 4 4 137 * 138 * discovery-v2 cont-> 139 * +------------------------------------------------------------------- 140 * | SP_FLAG | TX_KEY | TX_IDX | RX_KEY | RX_IDX | WEIGHT | BFLAGS | .. 141 * +------------------------------------------------------------------- 142 * 4 6 4 6 4 4 4 143 * 144 * cont-> 145 * -----------------+ 146 * .. | UNIT | PORT | 147 * -----------------+ 148 * 4 4 149 * 150 * When the compiler flag DISCOVER_APP_DATA_BOARDID is set, 151 * discovery-v2 will use the APP_DATA field to set the board-id 152 * and CPU base flag information as follows, 153 * 154 * discovery-v2 155 * --------------------------------- 156 * .. | APP_DATA | .. 157 * --------------------------------- 158 * .. | BOARDID | BASE_FLAG | .. (when DISCOVER_APP_DATA_BOARID) 159 * --------------------------------- 160 * 4 4 161 * 162 **************** 163 * 164 * Config Packet Entry 165 * 166 * <config-pkt-entry> 167 * +-----------------------+ 168 * | MASTER_KEY | MSEQ_NUM | 169 * +-----------------------+ 170 * 6 4 171 * 172 * The config packet: Confirmation of discovery completion 173 * between the master and each other CPU in the system. The 174 * master sends one packet to each other CPU and each CPU 175 * responds with a config packet. The master considers discovery 176 * to be complete when it has received a cfg packet from every other 177 * CPU in the system. Each other member of the stack considers 178 * discovery complete after it has received the cfg pkt from the 179 * master and responded with its own. 180 * 181 * The base format is the same as a probe packet (discovery header 182 * is the same). 183 * 184 * The "ENTRY_COUNT" in the discovery header holds the number of 185 * CPUs in the source's database. The config packet simply holds 186 * the MASTER_KEY and that entry's discovery sequence number as 187 * calculated by the source. 188 */ 189 190 191 #define DISC_VER_OFS 0 192 #define DISC_RSVD_OFS (DISC_VER_OFS + 1) 193 #define DISC_PROBE_TTL_OFS DISC_RSVD_OFS 194 #define LOCAL_PKT_TYPE_OFS (DISC_RSVD_OFS + 1) 195 #define ENTRY_COUNT_OFS (LOCAL_PKT_TYPE_OFS + 1) 196 #define SRC_DSEQ_NUM_OFS (ENTRY_COUNT_OFS + 1) 197 #define ENTRY_START_OFS (SRC_DSEQ_NUM_OFS + sizeof(uint32)) 198 #define DISC_HEADER_BYTES ENTRY_START_OFS 199 200 /* More in header for config packets. */ 201 #define CFG_MASTER_KEY_OFS ENTRY_START_OFS 202 #define CFG_MSEQ_NUM_OFS (CFG_MASTER_KEY_OFS + CPUDB_KEY_BYTES) 203 /* CFG_HEADER_BYTES includes discovery header */ 204 #define CFG_HEADER_BYTES (CFG_MSEQ_NUM_OFS + sizeof(uint32)) 205 206 /* These are for probe only; relative to start of probe entry */ 207 #define PROBE_KEY_OFS 0 208 #define PROBE_MAC_OFS CPUDB_KEY_BYTES 209 #define PROBE_DSEQ_NUM_OFS (PROBE_MAC_OFS + sizeof(bcm_mac_t)) 210 #define PROBE_RX_IDX_OFS (PROBE_DSEQ_NUM_OFS + sizeof(uint32)) 211 #define PROBE_TX_IDX_OFS (PROBE_RX_IDX_OFS + 1) 212 213 #define PROBE_ENTRY_BYTES (PROBE_TX_IDX_OFS + 1) 214 215 /* Offset of entry from start of discovery payload */ 216 #define PROBE_ENTRY_OFS(i) (ENTRY_START_OFS + (i) * PROBE_ENTRY_BYTES) 217 218 /* These are for routing only; relative to start of route entry */ 219 #define ROUTE_KEY_OFS 0 220 #define ROUTE_MAC_OFS (ROUTE_KEY_OFS + CPUDB_KEY_BYTES) 221 222 #define ROUTE_DSEQ_NUM_OFS (ROUTE_MAC_OFS + sizeof(bcm_mac_t)) 223 #define ROUTE_FLAGS_OFS (ROUTE_DSEQ_NUM_OFS + sizeof(uint32)) 224 #define ROUTE_SLOT_ID_OFS (ROUTE_FLAGS_OFS + sizeof(uint32)) 225 #define ROUTE_MASTER_PRI_OFS (ROUTE_SLOT_ID_OFS + sizeof(uint32)) 226 227 #define ROUTE_APP_DATA_OFS (ROUTE_MASTER_PRI_OFS + sizeof(uint32)) 228 229 #define ROUTE_NUM_UNITS_OFS (ROUTE_APP_DATA_OFS + CPUDB_APP_DATA_BYTES) 230 #define ROUTE_DEST_UNIT_OFS (ROUTE_NUM_UNITS_OFS + sizeof(uint32)) 231 #define ROUTE_DEST_PORT_OFS (ROUTE_DEST_UNIT_OFS + sizeof(uint32)) 232 #define ROUTE_STK_COUNT_OFS (ROUTE_DEST_PORT_OFS + sizeof(uint32)) 233 #define ROUTE_MOD_ID_OFS (ROUTE_STK_COUNT_OFS + sizeof(uint32)) 234 /* PER-Unit mod_ids_req and pref_mod_id arrays follow here */ 235 #define ROUTE_STK_ENTRY_OFS(num_units) \ 236 (ROUTE_MOD_ID_OFS + (num_units) * 2 * sizeof(uint32)) 237 238 #define ROUTE_BASE_BYTES(num_units) \ 239 (ROUTE_STK_ENTRY_OFS(num_units) - ROUTE_KEY_OFS) 240 241 #define STK_ENTRY_FLAG_OFS 0 242 #define STK_ENTRY_TX_KEY_OFS (STK_ENTRY_FLAG_OFS + sizeof(uint32)) 243 #define STK_ENTRY_TX_IDX_OFS (STK_ENTRY_TX_KEY_OFS + CPUDB_KEY_BYTES) 244 #define STK_ENTRY_RX_KEY_OFS (STK_ENTRY_TX_IDX_OFS + sizeof(uint32)) 245 #define STK_ENTRY_RX_IDX_OFS (STK_ENTRY_RX_KEY_OFS + CPUDB_KEY_BYTES) 246 #define STK_ENTRY_WEIGHT_OFS (STK_ENTRY_RX_IDX_OFS + sizeof(uint32)) 247 #define STK_ENTRY_BFLAGS_OFS (STK_ENTRY_WEIGHT_OFS + sizeof(uint32)) 248 #define STK_ENTRY_UNIT_OFS (STK_ENTRY_BFLAGS_OFS + sizeof(uint32)) 249 #define STK_ENTRY_PORT_OFS (STK_ENTRY_UNIT_OFS + sizeof(uint32)) 250 251 /* These are used to pre-allocate packet buffers for routing packets */ 252 #define ROUTE_ENTRIES_PER_PKT_MAX 4 /* Max entries allowed/pkt */ 253 #define ROUTE_PKTS_MAX CPUDB_CPU_MAX /* Max route pkts for table */ 254 #define ROUTE_PKT_BYTES_MAX 1500 /* Max route pkts for table */ 255 256 #endif /* _DISC_INT_H_ */