topology.h (4026B)
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: topology.h 8 * Purpose: 9 */ 10 11 #ifndef _STKTASK_TOPOLOGY_H_ 12 #define _STKTASK_TOPOLOGY_H_ 13 14 #include <sdk_config.h> 15 #include <appl/cpudb/cpudb.h> 16 17 #ifndef TOPO_MODIDS_MAX 18 #define TOPO_MODIDS_MAX 128 19 #endif 20 #ifndef TOPO_DEFAULT_WEIGHT 21 #define TOPO_DEFAULT_WEIGHT 1 22 #endif 23 #define TOPO_CXN_UNKNOWN 0xff 24 25 26 /* Flag: Force callback even if topology doesn't change */ 27 #define TOPO_F_FORCE_AP_CALL 0x1 28 29 /* 30 * tp_tx_cxns[src][dest] is the stack port index (relative to 31 * DB in context) of the port in "src" which should be used 32 * to reach "dest". src and dest are "topo indexes", that 33 * is just the ordinal index in which the CPUs appear when 34 * iterating through the DB. 35 * 36 * tp_rx_cxns[dest][src] indicates the stack port index 37 * in "dest" on which packets from CPU "src" should be expected. 38 * This is used for programming blocking registers, etc, in 39 * fabrics. 40 */ 41 42 typedef struct topo_info_s topo_info_t; 43 struct topo_info_s { 44 uint8 *tp_tx_cxns; /* "by hand" 2D array, num_cpu x num_cpu. */ 45 uint8 *tp_rx_cxns; 46 }; 47 48 typedef struct topo_stk_port_s topo_stk_port_t; 49 struct topo_stk_port_s { 50 uint8 flags; /* TOPO_CUT_PORT */ 51 int tx_mod_num; 52 uint8 tx_mods[TOPO_MODIDS_MAX]; 53 int rx_mod_num; 54 uint8 rx_mods[TOPO_MODIDS_MAX]; 55 }; 56 57 #define TOPO_CUT_PORT 0x1 58 59 typedef struct topo_cpu_s topo_cpu_t; 60 struct topo_cpu_s { 61 /* Info recorded from local entry of completed DB or from topo pkt */ 62 cpudb_entry_t local_entry; 63 64 uint8 version; 65 uint16 master_seq_num; 66 uint8 flags; 67 topo_stk_port_t tp_stk_port[CPUDB_CXN_MAX]; 68 int num_cpus; 69 uint16 ap_cookie; 70 }; 71 72 typedef int (*topology_mod_id_assign_f)(cpudb_ref_t db_ref); 73 74 /**************************************************************** 75 * 76 * Topology application function APIs. 77 */ 78 79 /* In topology.c: Generic topology processing */ 80 81 extern int topology_create(cpudb_ref_t db_ref); 82 extern int topology_destroy(cpudb_ref_t db_ref); 83 extern int topology_mod_ids_assign(cpudb_ref_t db_ref); 84 extern int topo_reserved_modid_set(uint32 modid, int enable); 85 extern int topo_reserved_modid_get(uint32 *modid); 86 extern int topology_mod_id_assign_function(topology_mod_id_assign_f func); 87 88 extern int topo_tx_port_get( 89 cpudb_ref_t db_ref, 90 cpudb_entry_t *src_entry, 91 cpudb_entry_t *dest_entry, 92 int *stk_idx); 93 94 /* 95 * Some useful topology iterator macros 96 * 97 * topo_cpu_t *topo_info; 98 * cpudb_stk_port_t *stk_p; 99 */ 100 101 /* Iterate over stack port info including flags and CPU cxns */ 102 #define TOPO_FOREACH_STK_PORT_INFO(stk_p, topo_info, sp_idx) \ 103 for (sp_idx = 0, stk_p = &(topo_info)->local_entry.stk_ports[0]; \ 104 sp_idx < (topo_info)->local_entry.base.num_stk_ports; \ 105 stk_p = &(topo_info)->local_entry.base.stk_ports[++sp_idx]) 106 107 /* Iterate over base stack port info (unit, port) */ 108 #define TOPO_FOREACH_STK_PORT(port_p, topo_info, sp_idx) \ 109 for (sp_idx = 0, port_p = &(topo_info)->local_entry.base.stk_ports[0]; \ 110 sp_idx < (topo_info)->local_entry.base.num_stk_ports; \ 111 port_p = &(topo_info)->local_entry.base.stk_ports[++sp_idx]) 112 113 #define TOPO_FOREACH_TX_MODID(mod_id, topo_info, sp_idx, idx) \ 114 for (idx = 0, mod_id = (topo_info)->tp_stk_port[sp_idx].tx_mods[0]; \ 115 idx < (topo_info)->tp_stk_port[sp_idx].tx_mod_num; \ 116 mod_id = (topo_info)->tp_stk_port[sp_idx].tx_mods[++idx]) 117 118 #define TOPO_FOREACH_RX_MODID(mod_id, topo_info, sp_idx, idx) \ 119 for (idx = 0, mod_id = (topo_info)->tp_stk_port[sp_idx].rx_mods[0]; \ 120 idx < (topo_info)->tp_stk_port[sp_idx].rx_mod_num; \ 121 mod_id = (topo_info)->tp_stk_port[sp_idx].rx_mods[++idx]) 122 123 #endif /* _STKTASK_TOPOLOGY_H_ */