disc.h (5318B)
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-2020 Broadcom Inc. All rights reserved. 6 * 7 * File: disc.h 8 * Purpose: Stack Discovery Algorithm 9 */ 10 11 #ifndef _DISCOVERY_DISC_H_ 12 #define _DISCOVERY_DISC_H_ 13 14 #include <sdk_config.h> 15 #include <shared/idents.h> 16 17 #include <bcm/types.h> 18 #include <bcm/rx.h> 19 20 #include <appl/cputrans/next_hop.h> 21 #include <appl/cpudb/cpudb.h> 22 23 #define DISC_PKT_TYPE_PROBE SHARED_PKT_TYPE_PROBE 24 #define DISC_PKT_TYPE_ROUTING SHARED_PKT_TYPE_ROUTING 25 #define DISC_PKT_TYPE_CONFIG SHARED_PKT_TYPE_CONFIG 26 #define DISC_NH_PKT_TYPE SHARED_PKT_TYPE_DISC_NH 27 #define DISC_CONFIG_CLIENT_ID SHARED_CLIENT_ID_DISC_CONFIG 28 29 #define DISCOVERY_VERSION_0 0 30 #define DISCOVERY_VERSION_1 1 31 #define DISCOVERY_VERSION_2 2 32 #define DISCOVERY_VERSION_DEFAULT DISCOVERY_VERSION_2 33 34 /* 35 * Default values in microseconds for 36 * DISC_TIMEOUT_DEFAULT 37 * overall timeout (before discovery fails) 38 * DISC_CFG_TO_DEFAULT 39 * mark stk ports w/o probe pkts as inactive 40 * DISC_RETRX_DEFAULT 41 * retransmit max times (re-send more probe/route packets) 42 * DISC_RETRX_MIN_DEFAULT 43 * retransmit min times (min time between retrx) 44 * DISC_ABORT_TIMEOUT_DEFAULT 45 * abort timeout (how long to wait for thread to ACK abort) 46 */ 47 48 #ifndef DISC_TIMEOUT_DEFAULT 49 #define DISC_TIMEOUT_DEFAULT (10 * 1000000) /* 10 seconds */ 50 #endif 51 #ifndef DISC_CFG_TO_DEFAULT 52 #define DISC_CFG_TO_DEFAULT (1000000) /* 1 second */ 53 #endif 54 #ifndef DISC_RETRX_DEFAULT 55 #define DISC_RETRX_DEFAULT (200000) /* 0.2 second */ 56 #endif 57 58 #ifndef DISC_RETRX_MIN_DEFAULT 59 #define DISC_RETRX_MIN_DEFAULT (100000) /* 0.1 second */ 60 #endif 61 #ifndef DISC_ABORT_TIMEOUT_DEFAULT 62 #define DISC_ABORT_TIMEOUT_DEFAULT (1000000) /* 1 second */ 63 #endif 64 65 #ifndef TRANS_PTR_DEFAULT 66 #define TRANS_PTR_DEFAULT (&bcm_trans_ptr) 67 #endif 68 69 /* Flags for ATP config client; applications may make this "no-ACK" */ 70 #ifndef DISC_CONFIG_ATP_FLAGS_DEFAULT 71 #define DISC_CONFIG_ATP_FLAGS_DEFAULT ATP_F_NEXT_HOP 72 #endif 73 extern uint32 disc_config_atp_flags; 74 75 /* 76 * These are the discovery return values used by Stack Task. 77 * 78 * DISC_RESTART_NEW_SEQ is a return value from disc_start indicating a 79 * hard restart is requested. This can be returned, for example, when 80 * discovery has given up on a stack port as being active, but then a 81 * probe packet is received indicating the port is alive. 82 * 83 * DISC_RESTART_REQUEST is an indication from discovery that it needs 84 * to be restarted, but not necessarily with a new sequence number. 85 */ 86 #define DISC_RESTART_REQUEST 1 87 #define DISC_RESTART_NEW_SEQ 2 88 #define DISC_PROBE_RECEIVED 3 89 90 typedef int (*disc_cb_t)(cpudb_ref_t db_ref, int status, void *user_data); 91 92 93 /* 94 * A lower transmit delay is preferred when TTL is enabled, especially 95 * in simplex systems. 96 * 97 * Note that the system must reach the maximum necessary TTL (and process 98 * packets) before reaching timeout. Timeout, PROBE_DELAY and 99 * TTL max should be properly adjusted. 100 */ 101 102 extern int disc_retrx_min_us; 103 104 /* 105 * Probe packet time-to-live is the number of hops a probe packet is 106 * permitted to be forwarded. If it is 0, it is disabled and the 107 * packet will not be filtered before it reaches it's point of 108 * origination. 109 * 110 * For systems with only duplex links, TTL can be set to 2. Otherwise, 111 * max TTL needs to be at least the number of CPUs in the system (in 112 * particular for simplex ring topologies.) 113 */ 114 115 #ifndef DISC_TTL_MIN_DEFAULT 116 #define DISC_TTL_MIN_DEFAULT 2 117 #endif 118 #ifndef DISC_TTL_MAX_DEFAULT 119 #define DISC_TTL_MAX_DEFAULT CPUDB_CPU_MAX 120 #endif 121 122 typedef int (*disc_start_election_cb_t)(cpudb_ref_t db_ref); 123 typedef int (*disc_election_cb_t)(cpudb_ref_t db_ref, void *user_data); 124 125 extern int disc_start(cpudb_ref_t db_ref, disc_start_election_cb_t m_elect); 126 extern int disc_abort(int disc_rv, int timeout_us); 127 128 extern int disc_timeout_set(int timeout_us, int cfg_to_us, int retrx_us); 129 extern int disc_timeout_get(int *timeout_us, int *cfg_to_us, int *retrx_us); 130 extern int disc_trans_ptr_set(bcm_trans_ptr_t *trans_ptr); 131 extern int disc_trans_ptr_get(bcm_trans_ptr_t **trans_ptr); 132 133 extern int disc_cos_set(int cos); 134 extern int disc_cos_get(int *cos); 135 extern int disc_vlan_set(int vlan); 136 extern int disc_vlan_get(int *vlan); 137 extern int disc_version_set(int version); 138 extern int disc_version_get(int *version); 139 extern int disc_ttl_min_set(int ttl_min); 140 extern int disc_ttl_min_get(int *ttl_min); 141 extern int disc_ttl_max_set(int ttl_max); 142 extern int disc_ttl_max_get(int *ttl_max); 143 extern int disc_fallback_set(int enable); 144 extern int disc_fallback_get(int *enable); 145 extern int disc_pkt_type_get(uint8 *pkt_buf); 146 extern int disc_election_register(disc_election_cb_t m_elect, 147 void *user_data); 148 extern int disc_election_unregister(disc_election_cb_t m_elect, 149 void *user_data); 150 extern int disc_run(cpudb_ref_t db_ref); 151 extern int disc_register(disc_cb_t callback, void *user_data); 152 extern int disc_unregister(disc_cb_t callback, void *user_data); 153 extern int disc_init(void); 154 extern int disc_deinit(void); 155 156 #endif /* _DISCOVERY_DISC_H_ */