ll.h (11495B)
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: ll.h 8 * Purpose: Link Layer interface (MAC and PHY) 9 */ 10 11 #ifndef _SOC_LL_H 12 #define _SOC_LL_H 13 14 #include <shared/port.h> 15 #include <shared/phyconfig.h> 16 17 #include <soc/defs.h> 18 #include <soc/macipadr.h> 19 #include <soc/portmode.h> 20 #include <soc/port_ability.h> 21 #include <soc/phyctrl.h> 22 23 /* Device specific MAC control settings */ 24 typedef enum soc_mac_control_e { 25 SOC_MAC_CONTROL_RX_SET, 26 SOC_MAC_CONTROL_TX_SET, 27 SOC_MAC_CONTROL_FRAME_SPACING_STRETCH, 28 SOC_MAC_CONTROL_SW_RESET, 29 SOC_MAC_CONTROL_TIMESTAMP_TRANSMIT, 30 SOC_MAC_CONTROL_DISABLE_PHY, 31 SOC_MAC_PASS_CONTROL_FRAME, 32 SOC_MAC_CONTROL_PFC_TYPE, 33 SOC_MAC_CONTROL_PFC_OPCODE, 34 SOC_MAC_CONTROL_PFC_CLASSES, 35 SOC_MAC_CONTROL_PFC_MAC_DA_OUI, 36 SOC_MAC_CONTROL_PFC_MAC_DA_NONOUI, 37 SOC_MAC_CONTROL_PFC_RX_PASS, 38 SOC_MAC_CONTROL_PFC_RX_ENABLE, 39 SOC_MAC_CONTROL_PFC_TX_ENABLE, 40 SOC_MAC_CONTROL_PFC_FORCE_XON, 41 SOC_MAC_CONTROL_PFC_STATS_ENABLE, 42 SOC_MAC_CONTROL_PFC_REFRESH_TIME, 43 SOC_MAC_CONTROL_PFC_XOFF_TIME, 44 SOC_MAC_CONTROL_LLFC_RX_ENABLE, 45 SOC_MAC_CONTROL_LLFC_TX_ENABLE, 46 SOC_MAC_CONTROL_EEE_ENABLE, 47 SOC_MAC_CONTROL_EEE_TX_IDLE_TIME, 48 SOC_MAC_CONTROL_EEE_TX_WAKE_TIME, 49 SOC_MAC_CONTROL_EEE_LINK_ACTIVE_DURATION, 50 SOC_MAC_CONTROL_FAULT_LOCAL_ENABLE, 51 SOC_MAC_CONTROL_FAULT_LOCAL_STATUS, 52 SOC_MAC_CONTROL_FAULT_REMOTE_ENABLE, 53 SOC_MAC_CONTROL_FAULT_REMOTE_STATUS, 54 SOC_MAC_CONTROL_PAD_SIZE, 55 SOC_MAC_CONTROL_FAILOVER_RX_SET, 56 SOC_MAC_CONTROL_FAULT_REMOTE_TX_ENABLE, 57 SOC_MAC_CONTROL_EGRESS_DRAIN, 58 SOC_MAC_CONTROL_RX_VLAN_TAG_OUTER_TPID, 59 SOC_MAC_CONTROL_RX_VLAN_TAG_INNER_TPID, 60 SOC_MAC_CONTROL_EXPECTED_RX_LATENCY, 61 SOC_MAC_CONTROL_COUNT /* always last */ 62 } soc_mac_control_t; 63 64 typedef struct soc_port_timesync_tx_info_s { 65 uint32 timestamps_in_fifo; /**< low 32bit of Timestamp in Fifo */ 66 uint32 timestamps_in_fifo_hi; /**< high 32 bit of timestamp in Fifo */ 67 uint32 sequence_id; /**< sequence id of sent ptp packet */ 68 } soc_port_timesync_tx_info_t; 69 70 /* 71 * Typedef: 72 * mac_driver_t 73 * Purpose: 74 * Maps out entry points into MAC drivers. 75 * Notes: 76 * Supplied functions are: 77 * 78 * md_init - Initialize the MAC to a known good state. 79 * md_enable_set - Enable MAC or disable and quiesce MAC. 80 * md_enable_get - Return current MAC enable state. 81 * md_duplex_set - Set the current operating duplex mode for the MAC. 82 * md_duplex_get - Return the current operating duplex mode for the MAC. 83 * md_speed_set - Set the current operating speed for the MAC 84 * md_speed_get - Return the current operating speed for the MAC. 85 * md_pause_set - Set current flow control mode. 86 * md_pause_get - Return current flow control mode. 87 * md_pause_addr_set - Set current flow control address. 88 * md_pause_addr_get - Return current flow control address. 89 * md_lb_set - Set current Loopback mode (enable/disable) for MAC. 90 * md_lb_get - Return current Loopback mode for MAC. 91 * md_interface_set - set MAC-PHY interface type (SOC_PORT_IF_*) 92 * md_interface_get - retrieve MAC-PHY interface type 93 * md_ability - Return mask of MAC abilities (from portmode.h) 94 * md_frame_max_set - Set the maximum receive frame size 95 * md_frame_max_get - Return the current maximum receive frame size 96 * md_ifg_set - set the inter-frame gap for the specified speed/duplex 97 * md_ifg_get - get the inter-frame gap for the specified speed/duplex 98 * md_encap_set - select port encapsulation mode (RAW/IEEE/HG/HG2) 99 * md_encap_get - get current port encapsulation mode 100 * md_control_set- set device specific controls 101 * md_control_get- get device specific controls 102 * md_timesync_tx_info_get - get timestamp and sequence id for two step timesync 103 * 104 * All routines return SOC_E_XXX values. 105 * Null pointers for routines will cause SOC_E_UNAVAIL to be returned. 106 * 107 * Macros are provided to access the fields. 108 */ 109 typedef struct mac_driver_s { 110 char *drv_name; 111 int (*md_init)(int, soc_port_t); 112 int (*md_enable_set)(int, soc_port_t, int); 113 int (*md_enable_get)(int, soc_port_t, int *); 114 int (*md_duplex_set)(int, soc_port_t, int); 115 int (*md_duplex_get)(int, soc_port_t, int *); 116 int (*md_speed_set)(int, soc_port_t, int); 117 int (*md_speed_get)(int, soc_port_t, int *); 118 int (*md_pause_set)(int, soc_port_t, int, int); 119 int (*md_pause_get)(int, soc_port_t, int *, int *); 120 int (*md_pause_addr_set)(int, soc_port_t, sal_mac_addr_t); 121 int (*md_pause_addr_get)(int, soc_port_t, sal_mac_addr_t); 122 int (*md_lb_set)(int, soc_port_t, int); 123 int (*md_lb_get)(int, soc_port_t, int *); 124 int (*md_interface_set)(int, soc_port_t, soc_port_if_t); 125 int (*md_interface_get)(int, soc_port_t, soc_port_if_t *); 126 int (*md_ability_get)(int, soc_port_t, soc_port_mode_t *); 127 int (*md_frame_max_set)(int, soc_port_t, int); 128 int (*md_frame_max_get)(int, soc_port_t, int *); 129 int (*md_ifg_set)(int, soc_port_t, int, soc_port_duplex_t, int); 130 int (*md_ifg_get)(int, soc_port_t, int, soc_port_duplex_t, int *); 131 int (*md_encap_set)(int, soc_port_t, int); 132 int (*md_encap_get)(int, soc_port_t, int *); 133 int (*md_control_set)(int, soc_port_t, soc_mac_control_t, int); 134 int (*md_control_get)(int, soc_port_t, soc_mac_control_t, int *); 135 int (*md_ability_local_get)(int, soc_port_t, soc_port_ability_t *); 136 int (*md_timesync_tx_info_get)(int, soc_port_t, soc_port_timesync_tx_info_t *); 137 } mac_driver_t; 138 139 #define _MAC_CALL(_md, _mf, _ma) \ 140 ((_md) == 0 ? SOC_E_PARAM : \ 141 ((_md)->_mf == 0 ? SOC_E_UNAVAIL : (_md)->_mf _ma)) 142 143 #define MAC_INIT(_md, _u, _p) \ 144 _MAC_CALL((_md), md_init, ((_u), (_p))) 145 146 #define MAC_ENABLE_SET(_md, _u, _p, _e) \ 147 _MAC_CALL((_md), md_enable_set, ((_u), (_p), (_e))) 148 149 #define MAC_ENABLE_GET(_md, _u, _p, _e) \ 150 _MAC_CALL((_md), md_enable_get, ((_u), (_p), (_e))) 151 152 #define MAC_DUPLEX_SET(_md, _u, _p, _d) \ 153 _MAC_CALL((_md), md_duplex_set, ((_u), (_p), (_d))) 154 155 #define MAC_DUPLEX_GET(_md, _u, _p, _d) \ 156 _MAC_CALL((_md), md_duplex_get, ((_u), (_p), (_d))) 157 158 #define MAC_SPEED_SET(_md, _u, _p, _s) \ 159 _MAC_CALL((_md), md_speed_set, ((_u), (_p), (_s))) 160 161 #define MAC_SPEED_GET(_md, _u, _p, _s) \ 162 _MAC_CALL((_md), md_speed_get, ((_u), (_p), (_s))) 163 164 #define MAC_PAUSE_SET(_md, _u, _p, _tx, _rx) \ 165 _MAC_CALL((_md), md_pause_set, ((_u), (_p), (_tx), (_rx))) 166 167 #define MAC_PAUSE_GET(_md, _u, _p, _tx, _rx) \ 168 _MAC_CALL((_md), md_pause_get, ((_u), (_p), (_tx), (_rx))) 169 170 #define MAC_PAUSE_ADDR_SET(_md, _u, _p, _m) \ 171 _MAC_CALL((_md), md_pause_addr_set, ((_u), (_p), (_m))) 172 173 #define MAC_PAUSE_ADDR_GET(_md, _u, _p, _m) \ 174 _MAC_CALL((_md), md_pause_addr_get, ((_u), (_p), (_m))) 175 176 #define MAC_LOOPBACK_SET(_md, _u, _p, _l) \ 177 _MAC_CALL((_md), md_lb_set, ((_u), (_p), (_l))) 178 179 #define MAC_LOOPBACK_GET(_md, _u, _p, _l) \ 180 _MAC_CALL((_md), md_lb_get, ((_u), (_p), (_l))) 181 182 #define MAC_INTERFACE_SET(_md, _u, _p, _i) \ 183 _MAC_CALL((_md), md_interface_set, ((_u), (_p), (_i))) 184 185 #define MAC_INTERFACE_GET(_md, _u, _p, _i) \ 186 _MAC_CALL((_md), md_interface_get, ((_u), (_p), (_i))) 187 188 #define MAC_ABILITY_GET(_md, _u, _p, _a) \ 189 _MAC_CALL((_md), md_ability_get, ((_u), (_p), (_a))) 190 191 #define MAC_ABILITY_LOCAL_GET(_md, _u, _p, _a) \ 192 _MAC_CALL((_md), md_ability_local_get, ((_u), (_p), (_a))) 193 194 #define MAC_FRAME_MAX_SET(_md, _u, _p, _s) \ 195 _MAC_CALL((_md), md_frame_max_set, ((_u), (_p), (_s))) 196 197 #define MAC_FRAME_MAX_GET(_md, _u, _p, _s) \ 198 _MAC_CALL((_md), md_frame_max_get, ((_u), (_p), (_s))) 199 200 #define MAC_IFG_SET(_md, _u, _p, _s, _d, _b) \ 201 _MAC_CALL((_md), md_ifg_set, ((_u), (_p), (_s), (_d), (_b))) 202 203 #define MAC_IFG_GET(_md, _u, _p, _s, _d, _b) \ 204 _MAC_CALL((_md), md_ifg_get, ((_u), (_p), (_s), (_d), (_b))) 205 206 #define MAC_ENCAP_SET(_md, _u, _p, _m) \ 207 _MAC_CALL((_md), md_encap_set, ((_u), (_p), (_m))) 208 209 #define MAC_ENCAP_GET(_md, _u, _p, _m) \ 210 _MAC_CALL((_md), md_encap_get, ((_u), (_p), (_m))) 211 212 #define MAC_CONTROL_SET(_md, _u, _p, _t, _v) \ 213 _MAC_CALL((_md), md_control_set, ((_u), (_p), (_t), (_v))) 214 215 #define MAC_CONTROL_GET(_md, _u, _p, _t, _v) \ 216 _MAC_CALL((_md), md_control_get, ((_u), (_p), (_t), (_v))) 217 218 #define MAC_TIMESYNC_TX_INFO_GET(_md, _u, _p, _info) \ 219 _MAC_CALL((_md), md_timesync_tx_info_get, ((_u), (_p), (_info))) 220 221 extern mac_driver_t soc_mac_ge; /* GEMAC */ 222 extern mac_driver_t soc_mac_fe; /* FEMAC */ 223 extern mac_driver_t soc_mac_big; /* BigMAC */ 224 extern mac_driver_t soc_mac_uni; /* UniMAC */ 225 extern mac_driver_t soc_mac_x; /* XMAC */ 226 extern mac_driver_t soc_mac_xl; /* XLMAC */ 227 extern mac_driver_t soc_mac_c; /* CMAC */ 228 extern mac_driver_t soc_mac_cl; /* CLMAC */ 229 extern mac_driver_t soc_mac_gx; /* 12G/10G/2.5G/1G combo MAC */ 230 extern mac_driver_t soc_mac_combo; /* generic combo MAC */ 231 extern mac_driver_t soc_mac_il; /* Interlaken */ 232 extern mac_driver_t soc_mac_ilkn; /* C3 Interlaken */ 233 234 /* 235 * Functions for selecting the MAC, and determining speed. 236 */ 237 238 extern int soc_mac_probe(int unit, soc_port_t port, mac_driver_t **); 239 240 typedef enum soc_mac_mode_e { 241 SOC_MAC_MODE_10_100, /* 10/100 Mb/s MAC selected */ 242 SOC_MAC_MODE_10, /* 10/100 Mb/s MAC in 10Mbps mode */ 243 SOC_MAC_MODE_1000_T, /* 1000/TURBO MAC selected */ 244 SOC_MAC_MODE_10000, /* 10G MAC selected */ 245 SOC_MAC_MODE_100000 /* 100G MAC selected */ 246 } soc_mac_mode_t; 247 extern int soc_mac_mode_set(int unit, soc_port_t port, 248 soc_mac_mode_t mode); 249 extern int soc_mac_mode_get(int unit, soc_port_t port, 250 soc_mac_mode_t *mode); 251 extern int soc_mac_speed_get(int unit, soc_port_t port, int *speed); 252 253 /* Media Access Controller Ethernet Frame Encapsulation mode */ 254 typedef _shr_port_encap_t soc_encap_mode_t; 255 256 #define SOC_ENCAP_IEEE _SHR_PORT_ENCAP_IEEE 257 #define SOC_ENCAP_HIGIG _SHR_PORT_ENCAP_HIGIG 258 #define SOC_ENCAP_B5632 _SHR_PORT_ENCAP_B5632 259 #define SOC_ENCAP_HIGIG2 _SHR_PORT_ENCAP_HIGIG2 260 #define SOC_ENCAP_HIGIG2_LITE _SHR_PORT_ENCAP_HIGIG2_LITE 261 #define SOC_ENCAP_HIGIG2_L2 _SHR_PORT_ENCAP_HIGIG2_L2 262 #define SOC_ENCAP_HIGIG2_IP_GRE _SHR_PORT_ENCAP_HIGIG2_IP_GRE 263 #define SOC_ENCAP_OBSOLETE _SHR_PORT_ENCAP_OBSOLETE 264 #define SOC_ENCAP_SOP_ONLY _SHR_PORT_ENCAP_PREAMBLE_SOP_ONLY 265 #define SOC_ENCAP_CPRI _SHR_PORT_ENCAP_CPRI 266 #define SOC_ENCAP_RSVD4 _SHR_PORT_ENCAP_RSVD4 267 #define SOC_ENCAP_COUNT _SHR_PORT_ENCAP_COUNT 268 269 #define SOC_ENCAP_MODE_NAMES_INITIALIZER _SHR_PORT_ENCAP_NAMES_INITIALIZER 270 271 extern int soc_autoz_set(int unit, soc_port_t port, int enable); 272 extern int soc_autoz_get(int unit, soc_port_t port, int *enable); 273 274 #endif /* !_SOC_LL_H */